I have a table with a sticky column (see jsfiddle below). But I´m trying to have a vertical scroll just on the table body so the headers are always visible and the height of tbody should be fixed. How can I do this?
body {
font: 16px Calibri;
}
table {
border-collapse: separate;
border-top: 3px solid grey;
}
td,th {
margin: 0;
border: 3px solid grey;
border-top-width: 0px;
white-space: nowrap;
}
div {
width: 600px;
overflow-x: scroll;
margin-left: 5em;
overflow-y: visible;
padding-bottom: 1px;
}
.headcol {
position: absolute;
width: 5em;
left: 0;
top: auto;
border-right: 0px none black;
border-top-width: 3px;
/*only relevant for first row*/
margin-top: -3px;
/*compensate for top border*/
}
.long {
background: yellow;
letter-spacing: 1em;
}
<div>
<table>
<thead>
<tr>
<th class="headcol">sticky col</th>
<th>col2</th>
<th>col3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="headcol">1</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</tbody>
</table>
</div>
The end result should be similar to this:
http://demos.telerik.com/kendo-ui/grid/frozen-columns
You will need to set the position to fixed of the cell that you would like to remain fixed during vertical scroll.
.headcol {
position:fixed;
}
Related
I am working with HTML tables and need to achieve like attached image.
When I try to achieve this,I caught problem like this
① I couldn't figure out how not to display border line.
② Each cell size is not aligned compared to desired result.
I would like to achieve in a certain way. If you have any opinion, please let me know.
Thanks
table {
border-collapse:collapse;
table-layout: fixed;
text-align: center;
width: 10rem;
height: 10rem;}
td {
border:solid black 1px;
}
.noborder {
}
.noborder2{
}
<table>
<tbody>
<tr>
<td class="noborder">Total (summary)</td>
<td class="noborder"></td>
<td class="noborder"></td>
<td class="noborder"></td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td class="noborder2"></td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>6</td>
</tr>
</tbody>
</table>
You can do something like this using empty-cells: hide;.
Note: but the border is bit off since it removes the td border where the content doesn't exists. If that's ok.
.tbl {
empty-cells: hide;
border: 1px solid #999;
}
td {
background: #fff;
border: 1px solid #999;
padding: 10px 15px;
cursor: pointer;
}
<table class="tbl" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="noborder">Total (summary)</td>
<td class="noborder"></td>
<td class="noborder"></td>
<td class="noborder"></td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td class="noborder2"></td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>6</td>
</tr>
</tbody>
</table>
Here is the another version:
.MainDiv {
border: 1px solid #999;
display: inline-block;
}
table.tbl {
empty-cells: hide;
}
td.noborder {
background: #fff;
border: 1px solid #999;
width: 50px;
height: 50px;
text-align: center;
}
td.removeBorder {
width: 100px;
height: 50px;
}
td:empty {
visibility: hidden;
}
<div class="MainDiv">
<table class="tbl" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td colspan="3" class="removeBorder">Total (summary)</td>
</tr>
<tr>
<td class="noborder">A</td>
<td class="noborder">B</td>
<td class="noborder">C</td>
<td class="noborder"></td>
</tr>
<tr>
<td class="noborder">1</td>
<td class="noborder">2</td>
<td class="noborder">3</td>
<td class="noborder">6</td>
</tr>
</tbody>
</table>
</div>
I´m trying to have a table with a sticky first column. The content in the sticky column is always in top of the probably because position is absolute.
How can I middle align the text in the sticky column?
table {
border-collapse: separate;
border-top: 3px solid grey;
}
td,
th {
margin: 0;
border: 3px solid grey;
border-top-width: 0px;
height: 30px;
}
div {
width: 600px;
overflow-x: scroll;
margin-left: 70px;
overflow-y: visible;
padding-bottom: 1px;
}
.stickycol {
line-height: 13px;
position: absolute;
width: 70px;
left: 0;
top: auto;
border-right: 0px none black;
border-top-width: 3px;
/*only relevant for first row*/
margin-top: -3px;
/*compensate for top border*/
word-wrap: break-word;
white-space: -moz-pre-wrap !important;
/* Mozilla, since 1999 */
white-space: -pre-wrap;
/* Opera 4-6 */
white-space: -o-pre-wrap;
/* Opera 7 */
white-space: pre-wrap;
/* css-3 */
word-wrap: break-word;
/* Internet Explorer 5.5+ */
white-space: -webkit-pre-wrap;
/* Newer versions of Chrome/Safari*/
word-break: break-all;
white-space: normal;
}
.long {
letter-spacing: 1em;
}
<div>
<table>
<thead>
<tr>
<th class="stickycol">col1</th>
<th>col2</th>
<th>col3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="stickycol">This text is so long</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</tbody>
</table>
</div>
You need to just add few css properties in the stickycol css class.
align-items:center and display:flex are for verically align
justify-content and text-align are for horizontally align.
see the snippet.
table {
border-collapse: separate;
border-top: 3px solid grey;
}
td,
th {
margin: 0;
border: 3px solid grey;
border-top-width: 0px;
height: 30px;
}
div {
width: 600px;
overflow-x: scroll;
margin-left: 70px;
overflow-y: visible;
padding-bottom: 1px;
}
.stickycol {
text-align:center;
justify-content:center;
align-items:center;
display:flex;
line-height: 13px;
position: absolute;
width: 70px;
left: 0;
top: auto;
border-right: 0px none black;
border-top-width: 3px;
/*only relevant for first row*/
margin-top: -3px;
/*compensate for top border*/
word-wrap: break-word;
white-space: -moz-pre-wrap !important;
/* Mozilla, since 1999 */
white-space: -pre-wrap;
/* Opera 4-6 */
white-space: -o-pre-wrap;
/* Opera 7 */
white-space: pre-wrap;
/* css-3 */
word-wrap: break-word;
/* Internet Explorer 5.5+ */
white-space: -webkit-pre-wrap;
/* Newer versions of Chrome/Safari*/
word-break: break-all;
white-space: normal;
}
.long {
letter-spacing: 1em;
}
<div>
<table>
<thead>
<tr>
<th class="stickycol">col1</th>
<th>col2</th>
<th>col3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="stickycol">This text is so long</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="stickycol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</tbody>
</table>
</div>
I'm quite inexperienced in all of this, but here's my problem. The columns in my table are being distributed weirdly. I'm doing this using Squarespace (don't judge), but I can edit the CSS and insert costume code. For some reason the first column is taking up a lot more space than the rest.
Here's what I've done:
.mytable {
border: 0px solid #009688;
width: 100%;
background-color: white;
white-space: nowrap;
overflow-x: auto;
display: block;
th {
padding: 4px;
text-align: left;
height:50px;
color: #eeeeee;
background-color: #009688;
}
td {
padding: 5px;
vertical-align: top;
border:0px;
line-height: 1.5em;
width: 100%;
}
tr:nth-child(odd) {
background-color: #E0F2F1
}
tr:nth-child(even) {
background-color: #fcfcfc
}
tr:hover {
background-color: #1DE9B6
}
}
<table class="mytable">
<tr>
<th>Menge</th>
<th>Bezeichnung</th>
</tr>
<tr>
<td>100 g</td>
<td>Geräucherter Lachs</td>
</tr>
<tr>
<td>2 Stück</td>
<td>Avocados</td>
</tr>
<tr>
<td>2 EL</td>
<td>Zitronensaft</td>
</tr>
<tr>
<td>½ Stück</td>
<td>Salatgurke</td>
</tr>
<tr>
<td>4 Stück</td>
<td>Eier</td>
</tr>
<tr>
<td>2 EL</td>
<td>Sesam</td>
</tr>
<tr>
<td>500 g</td>
<td>Sushireis</td>
</tr>
<tr>
<td>1 EL</td>
<td>Zucker</td>
</tr>
<tr>
<td>1 EL</td>
<td>Salz</td>
</tr>
<tr>
<td>4 EL</td>
<td>Reisessig</td>
</tr>
<tr>
<td>10 Stück</td>
<td>Noriblätter</td>
</tr>
<tr>
<td>1 Stück</td>
<td>Bambusmatte</td>
</tr>
</table>
Any suggestions? I should also add that I want the tables to be as responsive as possible (that's why I started playing with the CSS). Thanks!
.mytable {
border: 0px solid #009688;
background-color: white;
white-space: nowrap;
overflow-x: auto;
table-layout: fixed;
max-width: 600px;
width: 100%;
}
th {
padding: 10px;
text-align: left;
height:50px;
color: #eeeeee;
background-color: #009688;
width: 50%;
}
td {
padding: 10px;
vertical-align: top;
border:0px;
line-height: 1.5em;
width: 50%;
}
tr:nth-child(odd) {
background-color: #E0F2F1
}
tr:nth-child(even) {
background-color: #fcfcfc
}
tr:hover {
background-color: #1DE9B6
}
<table class="mytable">
<tr>
<th>Menge</th>
<th>Bezeichnung</th>
</tr>
<tr>
<td>100 g</td>
<td>Geräucherter Lachs</td>
</tr>
<tr>
<td>2 Stück</td>
<td>Avocados</td>
</tr>
<tr>
<td>2 EL</td>
<td>Zitronensaft</td>
</tr>
<tr>
<td>½ Stück</td>
<td>Salatgurke</td>
</tr>
<tr>
<td>4 Stück</td>
<td>Eier</td>
</tr>
<tr>
<td>2 EL</td>
<td>Sesam</td>
</tr>
<tr>
<td>500 g</td>
<td>Sushireis</td>
</tr>
<tr>
<td>1 EL</td>
<td>Zucker</td>
</tr>
<tr>
<td>1 EL</td>
<td>Salz</td>
</tr>
<tr>
<td>4 EL</td>
<td>Reisessig</td>
</tr>
<tr>
<td>10 Stück</td>
<td>Noriblätter</td>
</tr>
<tr>
<td>1 Stück</td>
<td>Bambusmatte</td>
</tr>
</table>
I am able to add the scrollbar, but the problem I am facing is that when the header is too big, the header overflows and is not breaking down. I want the header text to break down to next line and the rest of the columns should take the same height as the header.
HTML:
<div id="outerdiv">
<div id="innerdiv">
<table>
<tr>
<td class="headcol">Big Rowwwww1</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</table>
</div>
</div>
CSS:
body {
font:16px Calibri;
}
table {
border-collapse:separate;
border-top: 3px solid grey;
}
td {
margin:0;
border:3px solid grey;
border-top-width:0px;
white-space:nowrap;
}
#outerdiv {
position: absolute;
top: 0;
left: 0;
right: 5em;
}
#innerdiv {
width: 100%;
overflow-x:scroll;
margin-left: 5em;
overflow-y:visible;
padding-bottom:1px;
}
.headcol {
position:absolute;
width:5em;
left:0;
top:auto;
border-right: 0px none black;
border-top-width:3px;
/*only relevant for first row*/
margin-top:-3px;
/*compensate for top border*/
}
.headcol:before {
content:'Row ';
}
.long {
background:yellow;
letter-spacing:1em;
}
The current working code is below in the fiddle link
http://jsfiddle.net/DYgD6/693/
body {
font: 16 px Calibri;
}
table {
border - collapse: separate;
border - top: 3 px solid grey;
}
td {
margin: 0;
border: 3 px solid grey;
border - top - width: 0 px;
/*white-space:nowrap;*/
height: 80 px;
}#
outerdiv {
position: absolute;
top: 0;
left: 0;
right: 5e m;
}#
innerdiv {
width: 100 % ;
overflow - x: scroll;
margin - left: 5e m;
overflow - y: visible;
padding - bottom: 1 px;
}
.headcol {
position: absolute;
width: 5e m;
left: 0;
top: auto;
border - right: 0 px none black;
border - top - width: 3 px;
/*only relevant for first row*/
margin - top: -3 px;
/*compensate for top border*/
word - wrap: break -word;
}
.headcol: before {
content: 'Row ';
}
.long {
background: yellow;
letter - spacing: 1e m;
}
<div id="outerdiv">
<div id="innerdiv">
<table>
<tr>
<td class="headcol">Big Rowwwww1</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</table>
</div>
</div>
I have done few changes in your existing css, please look into the same and try this:
body {
font:16px Calibri;
}
table {
border-collapse:separate;
border-top: 3px solid grey;
}
td {
margin:0;
border:3px solid grey;
border-top-width:0px;
/*white-space:nowrap;*/
height:80px;
}
#outerdiv {
position: absolute;
top: 0;
left: 0;
right: 5em;
}
#innerdiv {
width: 100%;
overflow-x:scroll;
margin-left: 5em;
overflow-y:visible;
padding-bottom:1px;
}
.headcol {
position:absolute;
width:5em;
left:0;
top:auto;
border-right: 0px none black;
border-top-width:3px;
/*only relevant for first row*/
margin-top:-3px;
/*compensate for top border*/
word-wrap: break-word;
}
.headcol:before {
content:'Row ';
}
.long {
background:yellow;
letter-spacing:1em;
}
I've got problem with the table. On Firefox it looks great, but when I'm opening it on Chrome for first time table is in different position. Refresh repairs everything. What I did wrong?
CSS
#spec0{
background-color: #FFFFFF;
width: 566px;
border: 1px solid #ddd;
}
#spec1{
background-color: #F1F1F1;
width: 566px;
height: 20px;
}
#table {
border-collapse: collapse;
width: 566px;
border: 1px solid #ddd;
margin-top: 11px;
position: static;
}
#tr{
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
text-align: right;
}
#tr1{
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
}
#tr3{
height: 10px;
font-size: 11pt;
border: 1px solid #ddd;
text-align: left;
}
HTML
<table id="table">
<tr id="spec">
<th id="tr">Template</th>
<th id="tr3">Template</th>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr"></td>
<td id="tr1">Template</td>
</tr>
</table>
image; first launch from Chrome
You are using mutiple equal ID's , ID's must be unique , so change to class, and you were trying to apply #spec0 when you had only id="spec"
.spec {
background-color: #FFFFFF;
width: 566px;
border: 1px solid #ddd;
}
.spec1 {
background-color: #F1F1F1;
width: 566px;
height: 20px;
}
#table {
border-collapse: collapse;
width: 566px;
border: 1px solid #ddd;
margin-top: 11px;
position: static;
}
.tr {
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
text-align: right;
}
.tr1 {
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
}
.tr3 {
height: 10px;
font-size: 11pt;
border: 1px solid #ddd;
text-align: left;
}
<table id="table">
<tr class="spec">
<th class="tr">Template</th>
<th class="tr3">Template</th>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr"></td>
<td class="tr1">Template</td>
</tr>
</table>