Everything You Ever Wanted To Do With Tables Using CSS3
I wrote this CSS up recently for one of my ventures and figured it would be a good learning tool about some of the cool things you can do with advanced CSS.This CSS just about does it all:
- alternating row colors
- table td hover color
- table rounded borders
- compatability with CSS3 / Mozilla Firefox / Safari (sorry Internet Explorer, you suck)
- demonstrates the use of CSS pseudo classes
.results {
width:80%;
margin-left:20px;
}
.results th {
font-weight: bold;
text-align: center;
background-color:#fff;
}
.results td {
border-bottom: 1px solid #fff;
padding: 3px 10px;
vertical-align: middle;
}
.results tr td {
background-color: #ebebeb;
}
.results tr:nth-child(odd) td {
background-color: #dadada;
}
.results tr:first-child td:first-child {
-moz-border-radius-topleft:10px;
-webkit-border-top-left-radius:10px;
border-bottom-top-radius:10px;
}
.results tr:first-child td:last-child {
-moz-border-radius-topright:10px;
-webkit-border-top-right-radius:10px;
border-top-right-radius:10px;
}
.results tr:last-child td:first-child {
-moz-border-radius-bottomleft:10px;
-webkit-border-bottom-left-radius:10px;
border-bottom-left-radius:10px;
}
.results tr:last-child td:last-child {
-moz-border-radius-bottomright:10px;
-webkit-border-bottom-right-radius:10px;
border-bottom-right-radius:10px;
}
.results td:hover {
background-color: #99ccff;
}
Results:
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
You can also set cellspacing to 0 for the table to remove the gaps between cells. Do not use the border-collapse CSS, that messes up border rounding
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |
| Lorem | ipsum | dolor | sit | amet |




border-bottom-top-radius:10px;
Thanks!