Reputation: 67
I am trying to create rounded corners for my 3 column table (CSS table). I used:
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
in my CSS, but what I get is the top image. What I want it to look like is the bottom image.
Is there any way that this can be done?
Upvotes: 1
Views: 352
Reputation: 65361
If you want to do each row, use the CSS pseudo-classes :first-child
and :last-child
.
Demo: http://jsfiddle.net/ThinkingStiff/R792K/
CSS:
table { border-spacing: 0; }
td {
border-top: 1px solid black;
border-left: 1px solid black;
border-bottom: 1px solid black;
padding: 10px;
}
td:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
td:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-right: 1px solid black;
}
HTML:
<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
</table>
Upvotes: 3
Reputation: 14123
TD:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
TD:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
Upvotes: 2
Reputation: 1311
I'd suggest enclosing the whole table in a <div>
and then rounding the corners of that div
Upvotes: 2