css border not working on mouseover event in chrome? - html

The mouseover function is not working with Google Chrome. Working fine with Firefox and IE. While mouseover the border bottom is not disappearing. But if removing border-collapse: collapse it's working fine. Why is this? Any solution.
css:
html, body{
margin: 0;
padding: 0;
}
.table {
border-collapse: collapse;
}
.border {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #deecf9;
border-left: 0px;
border-right: 0px;
}
.border1 {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #deecf9;
border-left: 0px;
border-right: 0px;
}
.border2 {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #FFFFFF;
border-left: 0px;
border-right: 0px;
border-bottom: 0px;
padding: 1px;
}
Table:
<table width="1024" border="0" align="center" bgcolor="#FFFFFF" class="table">
<tr>
<td height="9" colspan="4" class="border"></td>
</tr>
<tr>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
</tr>
</table>

Do it like this: put an transparent border on your normal state elements.
When the :hover is applied the size of the border changes the size the element takes up.
eg:
.border1
{
border:1px solid #000000;
border-left:1px solid transparent;
border-right:1px solid transparent;
background-color: #FFFFFF;
}
.border1:hover
{
border:1px solid transparent;
border-top:1px solid #000000;
padding:1px;
background-color: #deecf9;
}
Your HTML should be something like:
<table width="1024" align="center" bgcolor="#FFFFFF" class="table">
<tr>
<td height="9" colspan="4" class="border"></td>
</tr>
<tr>
<td class="border1"> </td>
<td class="border1"> </td>
<td class="border1"> </td>
<td class="border1"> </td>
</tr>
</table>
No need to work with the mouseovers as an attribute, just use css.
Edit: i've noticed that you're using the css border-collapse property. This sets whether the table borders are collapsed into a single border or detached as in standard HTML. Try removing this line or set it to "separate", maybe this will work.

Related

Specify different styles for two different tr and td elements

I have two different tables on separate pages, and I need to specify a certain style to each one. This is my code (It works with separate stylesheets, but I need it to work on one):
Here is a snippet of my tables and the CSS:
body {
font-family: verdana;
}
/* Table 1 css */
.table1,
th,
td {
color: #030099;
border: 1px solid black;
border-width: 0px 1px 1px 1px;
font-size: 110%;
}
/* Table 2 css */
.pcsetup,
th,
td {
color: #030099;
border: 1px solid black;
border-width: 0px 1px 1px 1px;
font-size: 110%;
}
.tc1 {
background-color: white;
border: 2px solid black;
padding: 5px;
}
<h4>table 1</h4>
<table cellpadding="10" cellspacing="0" class="table1">
<caption class="tc1"><strong>My PC Setup</strong></caption>
<tr>
<th>Component</th>
</tr>
<tr>
<td><strong>CPU:</strong></td>
</tr>
<tr>
<td><strong>RAM:</strong></td>
</tr>
</table>
<h4>table 2</h4>
<table cellpadding="10" cellspacing="0" class="pcsetup">
<caption class="tc1"><b>PC Setup</b></caption>
<tr>
<th>Component</th>
</tr>
<tr>
<th><strong>CPU</strong></th>
</tr>
<tr>
<th><strong>RAM</strong></th>
</tr>
</table>
How can I differentiate between the two?

Zero border not working in html

I am doing an example having tables in a table, but parent table should not have border. I tried, but it is working. I check in W3School css tutorial also even no result. I tried:
style="border: none;"
border:0
Both not working in Chrome
th {
border: 1px solid black;
padding-left: 7px;
padding-right: 7px;
}
td {
border: 1px solid black;
padding-left: 7px;
padding-right: 7px;
}
<table id="t02" border="0">
<tr>
<td>
<table id="t01" style="border: 1px solid black; background-color: #E4E5E0; margin-left: 40px;">
<tr style="border: 1px solid black;">
<th>Available<br>On</th>
<th>Ids</th>
</tr>
<tr>
<td><b>Phone</b></td>
<td><b>9999999</td>
</tr>
</table>
</td>
<td>
<br><br>
<table id="t01" style="border: 1px solid black; background-color: #E4E5E0; margin-left: 40px;">
<tr style="border: 1px solid black;">
<th style="border: solid 1px black; padding-left: 7px; padding-right: 7px;">Available<br>On</th>
<th style="border: solid 1px black; padding-left: 7px; padding-right: 7px;">Ids</th>
</tr>
<tr>
<td><b>Phone</b></td>
<td><b>9999999</b></td>
</tr>
</table>
</td>
</tr>
</table>
Output
Several issues in your code...
...missing a closing bracket...
...why using inline styles...
...IDs should be unique - use a class for your "t01"...
But main important advice: do not use tables for layouting, these days.
Rather learn flexbox, or CSS grid.

rounders corners is not working in CSS

I have a email template design I am making. In the bottom of the page: [My Example Page][1] there is 2 buttons. THe button have a green border and a red border. I would like to set a 3px border on the green border, but I cannot make it work. I can only make it work for the border inside the green one.
Can anyone see why that happens?
table.button.secondary table td {
background: #e8e8e8;
color: #fefefe;
border-radius: 10px;
border: 1px solid green;
}
table.button.secondary table a {
color: #0d465d;
border: 0px solid #e8e8e8;
border-radius: 10px;
border: 1px solid red;
}
table.button.secondary:hover table td {
background: #e8e8e8;
color: #0d465d;
border: 1px solid #0d465d;
}
table.button.secondary:hover table a {
border: 0px solid #e8e8e8;
}
table.button.secondary:hover table td a {
color: #0d465d;
}
table.button.secondary:active table td a {
color: #0d465d;
}
table.button.secondary table td a:visited {
color: #fefefe;
}
<!-- Email Button Start -->
<table align="center" class="wrapper header float-center background-color__footer__blue">
<tbody>
<tr>
<td class="wrapper-inner">
<center>
<table align="center" class="container" style="background-color:transparent">
<tbody>
<tr>
<td>
<table class="row collapse">
<tbody>
<tr>
<th>
<center>
<table class="button secondary small-expanded">
<tr>
<td>
<table>
<tr>
<td style="text-align:center;" width="230">maim#mail.com
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</th>
<th class="expander"></th>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</td>
</tr>
</tbody>
</table>
<!-- Email Button End -->
You can change the table cell to be inline-block, but that may have unintended consequences.
table.button.secondary table td { display: inline-block; }
I would just make the a that has the red border currently a block element so that it takes up the entire table cell, then the border will look the same as if it was applied to the table cell instead. That's a better UX, too, since that's a clickable link and the border wraps the link - you should be able to click anywhere within the border to activate the link.
table.button.secondary table a {
color: #0d465d;
border: 0px solid #e8e8e8;
border-radius: 10px;
border: 1px solid red;
/* add these 2 lines */
display: block;
text-align: center;
}

Override the background in a HTML Table with CSS

I want to override the background of a table cell with a CSS definition, using class:
<table class="adminTable">
<thead>
<tr>
<th>Title</th>
<th align="center" width="50">%</th>
<th align="center">Actions</th>
</tr>
</thead>
<tbody>
<tr class="">
<td>Test</td>
<td align="center" class="IN_PROGRESS">27%</td>
<td align="center" width="175">
<a class="rounded-button" href="/admin/workflows/1/summary">Show</a>
<a class="rounded-button" href="/workflows/delete?id=1" class="button">Delete</a>
</td>
</tr>
</tbody>
</table>
The 'IN_PROGRESS' value varies with the different rows, and provides a colour indicating the status.
This is in my CSS style sheet:
.adminTable {
width: 100%;
border-width: 1px;
border-spacing: 2px;
border-style: outset;
border-color: gray;
border-collapse: separate;
background-color: WhiteSmoke ;
}
.adminTable th {
border-width: 1px;
padding: 5px;
border-style: dotted;
border-color: gray;
background-color: white;
-moz-border-radius: 10px;
}
.adminTable td {
border-width: 1px;
padding: 5px;
border-style: dotted;
border-color: gray;
background-color: white;
-moz-border-radius: 10px;
}
.IN_PROGRESS{
color:#FFFFFF;
background: DarkOrange;
}
Most of the time I just want the white background (and use this style all over my application), but here, and another few places I need to colour it. Is there an easy way to do this without having to duplicate the styles?
The problem is that .adminTable td is more specific (score {0}{1}{1}) than .IN_PROGRESS (score {0}{1}{0}).
Try td.IN_PROGRESS (score {0}{1}{1} but because it appears later in the CSS file it will win out) instead.
You should give complete css hierarchy for .IN_PROGRESS.
It will go as follows
.adminTable td.IN_PROGRESS {
color:#FFFFFF;
background: DarkOrange;
}

More efficient way to customize your borders in html

I am seeking for better way to arrange my borders.
Currently I have something like this, but I feel there must be some better and quick solution to this.
My Code:
<style>
td.left{
border-top-style:solid;
border-left-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.right{
border-top-style:solid;
border-right-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.updown{
border-top-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.left2{
border-left-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.right2{
border-right-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.updown2{
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.finish{
border-bottom-style: solid;
border-left-style: solid;
border-right-style: solid;
border-color: black;
border-width: 1px;
}
table {
border-style:none;
padding:1px;
margin:0px;
border-spacing: 0px;
border: 0pxborder: ;
width:850px;
}
</style>
I have created classes with each specific side to be displayed for each different purposes.
Here is the body part of the code, I have used class "left" for 1st row and "left2" for 2nd row, this is due to if I use both rows with "left" then second row will have thicker line between 1st row and 2nd row.
In this table I want to make lines between a specific column to disappear or appear but struggling to find shorter code to do so.
<table>
<tbody>
<tr>
<td width="149" class="left"> For testing 1</td>
<td width="312" class="updown"><input type="text" /></td>
<td width="172" class="left"> For testing 2</td>
<td width="204" class="right"> <input type="text" /></td>
</tr>
<tr>
<td class="left2">For testing 3</td>
<td class="right2" colspan="3"><input type="text" /></td>
</tr>
<tr>
<td class="left2" colspan="2">For testing 4</td>
<td class="finish" colspan="2"><input type="text" /></td>
</tr>
</tbody>
</table>
Here is a character-saving solution with border-collapse: collapse;
LIVE DEMO
HTML:
<table>
<tbody>
<tr>
<td><span>For testing 1</span><input type="text" /></td>
<td><span>For testing 2</span><input type="text" /></td>
</tr>
<tr>
<td colspan="2"><span>For testing 3</span><input type="text" /></td>
</tr>
<tr>
<td><span>For testing 4</span></td>
<td><input type="text" /></td>
</tr>
</tbody>
</table>
CSS:
td {
border: 1px solid black;
border-collapse: collapse;
}
table {
border: 1px solid black;
border-collapse: collapse;
width: 850px;
}
span {
float: left;
width: 150px;
}
What you could do is this:
td {
border:1px solid black;
}
td.left{
border-right-style:none;
}
td.right{
border-left:none;
}
td.updown{
border-left:none;
border-right:none;
}
td.left2{
border-top:none;
border-right:none;
}
td.right2{
border-left:none;
border-top:none;
}
td.updown2{
border-top:none;
border-left:none;
border-right:none;
}
td.finish{
border-top:none;
}
See: http://jsfiddle.net/Cuyxh/
However, I would suggest using classes for each border in your HTML, for a more modular approach.
Example:
b-left, b-right, b-top, b-down {
border-color:black;
border-width:1px;
}
b-left {
border-left-style:solid;
}
b-top {
border-top-style:solid;
}
b-right {
border-right-style:solid;
}
b-bottom {
border-bottom-style:solid;
}
And then adding these classes to your table cells. For example:
<td width="149" class="b-left b-top">For testing 1</td>