Magento2: Table border and hover - html

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>
Result:
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:
head hover effect:
td hover effect:
I want delete head hover effect. I need only td hover effect. Can anyone help me correct this code?

Here you go.
What I changed:
removed border from everywhere, and just added border-bottom property to table row.
removed hover background from thead by adding 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;
}
}

Related

Responsive HTML table using colspan

I'm trying to recreate the attached table to be responsive in a similar style as the below code.
I am unsure if I explaining myself well enough but I am having trouble figuring out how I can reference the min/max data which also shows up along with DK (mobile view)
<style>
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: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
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;
}
}
</style>
HTML
<table>
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col">Material characteristics yield strength <sub>M (N/mm²)</sub></th>
<th scope="col">Characteristic pull-out resistance <sub>f (N/mm²)</sub></th>
<th scope="col">Assigned density <sub>p (kg/m³)</sub></th>
<th scope="col">Characteristic head pull-through resistance <sub>f (N/mm²)</sub></th>
<th scope="col">Characteristic tensile resistance <sub>f {kN}</sub></th>
<th scope="col">Characteristic torsional resistance <sub>f (N*m)</sub></th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Product">WKCP Ø6</td>
<td data-label="Material characteristics yield strength">10.0 <sub>M (N/mm²)</sub></td>
<td data-label="Characteristic pull-out resistance">12.0 <sub>f (N/mm²)</sub></td>
<td data-label="Assigned density">350 <sub>p (kg/m³)</sub></td>
<td data-label="Characteristic head pull-through resistance">9.4 <sub>f (N/mm²)</sub></td>
<td data-label="Characteristic tensile resistance">13.0 <sub>f {kN}</sub></td>
<td data-label="Characteristic torsional resistance">10.0 <sub>f (N*m)</sub></td>
</tr>
<td scope="row" data-label="Account">WKCP Ø8</td>
<td data-label="Material characteristics yield strength">25.0 <sub>M (N/mm²)</sub></td>
<td data-label="Characteristic pull-out resistance">12.0 <sub>f (N/mm²)</sub></td>
<td data-label="Assigned density">350 <sub>p (kg/m³)</sub></td>
<td data-label="Characteristic head pull-through resistance">9.4 <sub>f (N/mm²)</sub></td>
<td data-label="Characteristic tensile resistance">25.0 <sub>f {kN}</sub></td>
<td data-label="Characteristic torsional resistance">27.0 <sub>f (N*m)</sub></td>
</tr>
<tr>
<td scope="row" data-label="Acount">WKCP Ø10</td>
<td data-label="Material characteristics yield strength">43.0 <sub>M (N/mm²)</sub></td>
<td data-label="Characteristic pull-out resistance">11.0 <sub>f (N/mm²)</sub></td>
<td data-label="Assigned density">350 <sub>p (kg/m³)</sub></td>
<td data-label="Characteristic head pull-through resistance">9.4 <sub>f (N/mm²)</sub></td>
<td data-label="Characteristic tensile resistance">36.0 <sub>f {kN}</sub></td>
<td data-label="Characteristic torsional resistance">45.0 <sub>f (N*m)</sub></td>
</tr>
</tbody>
</table>

change style to header in html table

I am learning css writing styles for an html table and I was wondering how I can remove the borders of the blank cell for the first row of my header, in addition to rounding the edges for the cells estimated amount and total.
I leave the html and css in addition to a thread of reproduction:
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
.blank {
background-color: #FFFFFF;
}
table tr {
background-color: #f8f8f8;
border: 2px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
<table>
<thead>
<tr>
<th class="blank"></th>
<th colspan="2">estimated amount</th>
<th>total</th>
</tr>
<tr>
<th scope="col">Account</th>
<th scope="col">Expense</th>
<th scope="col">Income</th>
<th scope="col">Diff</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$3,190</td>
<td data-label="Income">$1,000</td>
<td data-label="Diff">$2,190</td>
</tr>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$5,000</td>
<td data-label="Income">$1,000</td>
<td data-label="Diff">$4,000</td>
</tr>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$7,000</td>
<td data-label="Income">$4,000</td>
<td data-label="Diff">$3,000</td>
</tr>
</tbody>
</table>
this is a tricky one because applying border-radius while having the value of border-collapse set to collapse will not work the way you wanted it to.
My solution for you is to create your borders using CSS like this :
table {
border-collapse: separate;
border-spacing: 0;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
th ,td {
border-right:2px solid #ddd;
border-bottom: 2px solid #ddd;
background-color: #f8f8f8;
padding: .35em;
}
#tr1 th:last-child {
border-top: 2px solid #ddd;
}
#tr1 th:nth-child(2) {
border-left: 2px solid #ddd;
border-top: 2px solid #ddd;
}
#tr2 th:first-child{
border-top: 2px solid #ddd;
}
#tr2 th:first-child{
border-left: 2px solid #ddd;
}
tr td:first-child{
border-left: 2px solid #ddd;
}
.blank {
background-color: #FFFFFF;
border: none;
}
.estimatedAmountClass {
border-top-left-radius: 40px;
}
.totalClass {
border-top-right-radius: 40px;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
<table >
<thead>
<tr id="tr1">
<th class="blank"></th>
<th class="estimatedAmountClass" colspan="2">estimated amount</th>
<th class="totalClass">total</th>
</tr>
<tr id="tr2">
<th scope="col">Account</th>
<th scope="col">Expense</th>
<th scope="col">Income</th>
<th scope="col">Diff</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$3,190</td>
<td data-label="Income">$1,000</td>
<td data-label="Diff">$2,190</td>
</tr>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$5,000</td>
<td data-label="Income">$1,000</td>
<td data-label="Diff">$4,000</td>
</tr>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Expense">$7,000</td>
<td data-label="Income">$4,000</td>
<td data-label="Diff">$3,000</td>
</tr>
</tbody>
</table>

Colgroup and Col aren't visible on desktop

I have simple table on which I'm trying to add colgroup and col but they aren't visible. It is also partly break the responsiveness of the table.
On mobile version the red cols are visible but are wrong.
Here is the 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: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
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 {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
<table>
<caption>Statement Summary</caption>
<colgroup>
<col span="2" style="background-color:red; text-align: center;">
<col style="background-color:yellow">
</colgroup>
<thead>
<tr>
<th scope="col">Account</th>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<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>
</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>
</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>
</tr>
<tr>
<td scope="row" data-label="Account">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>
</tr>
</tbody>
</table>
And here is the Jsfiddle where you can see the responsiveness: https://jsfiddle.net/d5yfteck/
How can I use colgroup and col?
This line:
table tr {
background-color: #f8f8f8;
}
is overriding the colgroup definitions.
Without that line your code is working fine:
your code with colgroup
UPDATE:
If you wish to achieve the same effect on mobile,
in your mobile layout the columns presented as rows so one solution is to use classes in the media tag (.red .yellow), also see that tbody should be set with other color.

Insert line break after each tr tag row

I would like to add a line break after each tr tag so there a gap between the next row of data. I have included what I thought should work but alas, no luck. Basically, if there are 10 rows of data separate each tr with a new line.
I would be grateful if someone could point out my error. many thanks
UPDATE: Screen grab to show exactly how I want the row spacing to appear. Notice the spacing at the bottm of each row.
table tr {
/* background: #f8f8f8;*/
/*border: 1px solid #ddd;*/
}
table th, table td {
text-align: left;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
#media screen and (max-width: 600px) {
table {
border: 1px solid #eee;
border-radius: 5px !important;
}
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: 1px solid #ddd;*/
display: block;
/* margin-bottom: .625em;*/
}
table td {
/* border-bottom: 1px solid #ddd;*/
display: block;
font-size: .85em;
text-align: left;
/* margin-bottom: .625em;*/
}
table td:before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
/* border-bottom: 0;*/
content: "" !important;
white-space: pre !important;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="container">
<table class="table table-striped">
<caption>
<h3>Caption</h3>
</caption>
<thead>
<tr>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Due Date" scope="row">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
</tr>
</tbody>
</table>
</div>
I played a little with your code and ended up with this:
(I only added margin-bottom: 3em; in table tr td:last-child { … })
Feel free to comment if you want some modification.
table th,
table td {
text-align: left;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
#media screen and (max-width: 600px) {
table {
border: 1px solid #eee;
border-radius: 5px !important;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
display: block;
}
table td {
display: block;
font-size: .85em;
text-align: left;
}
table td:before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table tr td:last-child {
margin-bottom: 3em;
content: "" !important;
white-space: pre !important;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="container">
<table class="table table-striped">
<caption>
<h3>Caption</h3>
</caption>
<thead>
<tr>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Due Date" scope="row">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
</tr>
</tbody>
</table>
</div>
Hope it helps.
If I'm understanding you correctly, you just want an empty line between each row. If that's the case then you'd want to target the td tag not the tr tag. You would add padding-bottom: 1em; to all rows and specify that the last row has padding-bottom: 0;. Try this solution:
table th, table td {
text-align: left;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
#media screen and (max-width: 600px) {
table {
border: 1px solid #eee;
border-radius: 5px !important;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
display: block;
}
table td {
display: block;
font-size: .85em;
text-align: left;
padding-bottom: 1em;
}
table td:before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
content: "" !important;
white-space: pre !important;
}
table tr:last-child td:last-child{
padding-bottom: 0;
}
}
<div class="container">
<table class="table table-striped">
<caption>
<h3>Caption</h3>
</caption>
<thead>
<tr>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Due Date" scope="row">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<br/>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td data-label="Due Date" scope="row">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
</tr>
</tbody>
</table>
</div>
Olivier answer is good, but I think border-spacing is more appropriate here. Padding adds blank space INTO the cells which might have unwanted visual consequences (e.g. when border is displayed).
From what you asked, you probably want the empty space BETWEEN the cells. I would recommend something like this
table {
border-collapse: separate;
border-spacing: 0 10px; // or 0.85em but i would recommend using pixels here
}
The 0 is for horizontal spacing (which you don't want), 10px is for vertical spacing (thats the space between rows).

Clear gap between span and table

JSFiddle
I can't resolve the gap between a h2 tag and a table. Beside, if you look at my attached image, you will se that in the second table, the first row's width(header) is shorter than the rest, any help is greatly appreciated!
h2 and table css :
.tieudemien
{
line-height: 24px;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
width:498px;
margin-bottom: 0;
padding-bottom: 0;
margin-left:1px;
}
.tb {
width: 500px;
padding-top:0;
padding-bottom:0;
}
Padding issue:
table td {
padding: 0;
}
See it here: http://jsfiddle.net/uryeto61/4/
Here's result: http://jsfiddle.net/abruzzi/uryeto61/3/
You can just change the padding of class .tdkq and tddd below:
.tdkq, .tddd {
padding: 0;
}
demo - http://jsfiddle.net/victor_007/uryeto61/2/
add to table
cellpadding='0'
Try this -
table td{
padding: 0;
}
Set table td Padding 0
Try This:
body {} table,
th,
td,
tr {
border-collapse: collapse;
}
.tb {
width: 500px;
padding-top: 0;
padding-bottom: 0;
}
/*2 cell đầu tiên, xác định độ rộng*/
.tdkq {
width: 70%;
vertical-align: top;
}
.tddd {
width: 30%;
vertical-align: top;
}
/*bảng kết quả và đầu đuôi*/
.tbkq {
width: 100%;
word-wrap: break-word;
table-layout: fixed;
float: left;
margin-bottom: 0;
padding-bottom: 0;
border-right: 1px solid #CCC;
}
.tbdd {
width: 100%;
}
.tbdd td {
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
}
/*cột giải và kết quả của bảng kết quả*/
.trkq {
width: 100%;
}
.thkqgiai {
width: 20% !important;
text-align: center;
color: white;
background-color: #910000;
}
.thkqso {
width: 80% !important;
}
.tdkqgiai {
text-align: center;
background-color: #F9F9F9;
color: #910000;
}
.tdkqgiaidb {
text-align: center;
color: white;
background-color: #910000;
}
.tdkqso {
text-align: center;
word-wrap: break-word !important;
border-top: 1px solid #CCC;
}
.tdkqsodb {
text-align: center;
word-wrap: break-word !important;
color: red;
border-top: 1px solid #CCC;
}
/*cột đầu và đuôi của bảng đầu đuôi*/
.thdddau {
width: 30%;
color: white;
background-color: #910000;
}
.thddduoi {
width: 70%;
color: white;
background-color: #910000;
}
/*tiêu đề cho bảng kq*/
.tieudemien {
line-height: 24px;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
width: 500px;
margin-bottom: 0;
padding-bottom: 0;
margin-left: 1px;
}
.tieudecuoi {
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
margin-bottom: 0;
padding-top: 4px;
padding-bottom: 0;
width: 300px !important;
}
.tdtieudecuoi {
text-align: right;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
}
table td {
padding: 0;
}
<h2 class="tieudemien"> Kết quả xổ số Miền Bắc ngày 02-11-2014</h2>
<table class="tb">
<tbody>
<tr>
<td class="tdkq">
<table class="tbkq">
<tbody>
<tr class="trkq">
<th class="thkqgiai">Giải</th>
<th class="thkqso">BTB</th>
</tr>
<tr>
<td class="tdkqgiai">Đặc biệt</td>
<td class="tdkqsodb">23411</td>
</tr>
<tr>
<td class="tdkqgiai">Giải nhất</td>
<td class="tdkqso">37428</td>
</tr>
<tr>
<td class="tdkqgiai">Giải nhì</td>
<td class="tdkqso">38460-75356</td>
</tr>
<tr>
<td class="tdkqgiai">Giải ba</td>
<td class="tdkqso">02055-66542-36814-52154-66881-20546</td>
</tr>
<tr>
<td class="tdkqgiai">Giải bốn</td>
<td class="tdkqso">6300-7736-6062-3408</td>
</tr>
<tr>
<td class="tdkqgiai">Giải năm</td>
<td class="tdkqso">0235-2078-1344-6340-4550-6337</td>
</tr>
<tr>
<td class="tdkqgiai">Giải sáu</td>
<td class="tdkqso">046-421-944</td>
</tr>
<tr>
<td class="tdkqgiai">Giải bảy</td>
<td class="tdkqso">88-98-24-21</td>
</tr>
<tr>
<td class="tdtieudecuoi"></td>
<td class="tdtieudecuoi">span</td>
</tr>
</tbody>
</table>
</td>
<td class="tddd">
<table class="tbdd">
<tbody>
<tr class="trkq">
<th class="thdddau">Đầu</th>
<th class="thddduoi">Đuôi</th>
</tr>
<tr>
<td class="tdkqgiai">0</td>
<td class="tdkqso">0,8</td>
</tr>
<tr>
<td class="tdkqgiai">1</td>
<td class="tdkqso">1,4</td>
</tr>
<tr>
<td class="tdkqgiai">2</td>
<td class="tdkqso">8,1,4,1</td>
</tr>
<tr>
<td class="tdkqgiai">3</td>
<td class="tdkqso">6,5,7</td>
</tr>
<tr>
<td class="tdkqgiai">4</td>
<td class="tdkqso">2,6,4,0,6,4</td>
</tr>
<tr>
<td class="tdkqgiai">5</td>
<td class="tdkqso">6,5,4,0</td>
</tr>
<tr>
<td class="tdkqgiai">6</td>
<td class="tdkqso">0,2</td>
</tr>
<tr>
<td class="tdkqgiai">7</td>
<td class="tdkqso">8</td>
</tr>
<tr>
<td class="tdkqgiai">8</td>
<td class="tdkqso">1,8</td>
</tr>
<tr>
<td class="tdkqgiai">9</td>
<td class="tdkqso">8</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>