After some digging around on SO I found this as the best response for my need of having rounded corners for tables.
Which lead me to the following CSS snippet:
.greytable tr:first-child th:first-child {
-moz-border-radius-topleft: 5px;
-webkit-border-top-left-radius: 5px;
border-top-left-radius: 5px;
}
.greytable tr:first-child th:last-child {
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
border-top-right-radius: 5px;
}
.greytable tr:last-child td:first-child {
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.greytable tr:last-child td:last-child {
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
border-bottom-right-radius: 5px;
}
Now I’d like to know how I could simplify all these with LESS. I tried the following LESS code:
.border-radius (@v, @h, @radius: 5px) {
-moz-border-radius-@v@h: @radius;
-webkit-border-@v-@h: @radius;
border-@v-@h: @radius;
}
And then invoke it (for the top left corner):
.greytable tr:first-child th:first-child {
.border-radius('top', 'left')
}
But it doesn’t work (error on the second line of the LESS snippet).
Thanks in advance!
You might need to use the string interpolation syntax, try this:
I would also add that webkit and mozilla are largely up to speed with the standard
border-radiusproperty, and the vendor prefixes are becoming outdated for it.EDIT: It seems that string interpolation isn’t working out for this task (the above code won’t compile), so here’s a workaround mixin that will actually be easier to use:
Usage:
Output: