Reputation: 143
I have created simple css table.
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: white;
border: 1px solid #ddd;
padding: .35em;
}
table tr:hover {
background-color: #3b458e;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
<table>
<thead>
<tr>
<th scope="col">SKU</th>
<th scope="col">Image</th>
<th scope="col">EAN</th>
<th scope="col">Brand</th>
<th scope="col">Name</th>
<th scope="col">Size</th>
<th scope="col">Leadtime</th>
<th scope="col">MSRP</th>
<th scope="col">Price</th>
<th scope="col">Qty</th>
<th scope="col">Total</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Due Date">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
<td data-label="Account">Visa - 3412</td>
</tr>
<tr>
<td scope="row" data-label="Account">Visa - 6076</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
</tr>
<tr>
<td scope="row" data-label="Account">Corporate AMEX</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Due Date">03/01/2016</td>
</tr>
<tr>
<td scope="row" data-label="Acount">Visa - 3412</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Due Date">02/01/2016</td>
</tr>
</tbody>
</table>
How to removing the top, left and right border. (I want to leave only the bottom border)
Currently table head is hover, and td is hover:
I want delete head hover effect. I need only td hover effect. Can anyone help me correct this code?
Upvotes: 0
Views: 266
Reputation: 337
Here you go. What I changed:
border-bottom
property to table row.table thead tr:hover
with background:#fff;
table {
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: white;
padding: .35em;
border-bottom: 1px #cdcdcd solid;
}
table tr:hover {
background-color: #3b458e;
}
table thead tr:hover {
background-color: #fff;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
Upvotes: 1