I'm hardly an expert in css, so this is a bit frustrating. I have a grid that was filled with a repeater. I want each row to have a 1px border along the bottom to visually separate the rows. I also want a dark gray border on each side of the table. With the following CSS for this table:
#repeaterTable
{
border-left: 1px solid #A3A3A3;
border-right: 1px solid #A3A3A3;
border-collapse: collapse;
}
repeaterTable.td
{
border-bottom: 1px solid white;
}
I am getting this result in FF (SS of right edge of table):
And this in IE8:
alt text http://img412.imageshack.us/img412/7092/borderie.png
What I need is to have the dark gray border remain solid, instead of break for each row border. The table has two columns in it, but the cellspacing is at 0px so setting the border-bottom on the tr makes a continuous border. Can anyone suggest some changes to the css to get this working?
Add a border-left and border-top to the parent. Add border-right and border-bottom to each of the children.
Best solution : Use border-collapse:collapse; for the <table> element.
Add a border, border color, or border line styleClick Home > the Borders arrow, and then pick the border option you want. Add a border line style - Click the Borders arrow > Border Style, and then pick a line style option.
Try this to get the effect you want:
#repeaterTable
{
border-left: 1px solid #A3A3A3;
border-right: 1px solid #A3A3A3;
border-collapse:collapse;
border-spacing:0px;
background-color:#ccc;
}
#repeaterTable td:first-child
{
border-left: 1px solid #A3A3A3;
}
#repeaterTable td:last-child
{
border-right: 1px solid #A3A3A3;
}
#repeaterTable td
{
border-bottom: 1px solid white;
}
Tested with the following markup in IE8 and FF (doesn't work in Chrome/Safari :( ).
<table id="repeaterTable">
<tr> <td> </td><td> </td> </tr>
<tr> <td> </td><td> </td> </tr>
<tr> <td> </td><td> </td> </tr>
<tr> <td> </td><td> </td> </tr>
</table>
Using this CSS will get it looking like you want it to in IE/Safari/FF/Chrome. The problem is the border-collapse, it is what is causing the continuation of the white border into the table border. If you remove that (and add back in cellpadding="0" and cellspacing="0") and go with this CSS:
#repeaterTable
{
border-left: 1px solid #A3A3A3;
border-right: 1px solid #A3A3A3;
background: #CCC;
}
#repeaterTable td
{
border-bottom: 1px solid white;
}
#repeaterTable td.last
{
border-bottom: 0px;
}
With this HTML:
<table id="repeaterTable" cellpadding="0" cellspacing="0">
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td class="last"> </td></tr>
</table>
It'll work.
You can use :last-child in the CSS but that isn't supported by older browsers (IE7/etc) so it'll look wrong there. Depends on how compatible you want to be. So instead I used a "last" class.
Alternately you could just wrap the table in a DIV that has the left and right border and then you only have to worry about the row borders and you can use collapse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With