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!
Click the Insert > Shapes button and choose the Rounded Rectangle tool.
Rounded corners are more effective for maps and diagrams because they allow our eyes to easily follow lines “as it suits better to the natural movement of the head and eyes respectively” [5]. Sharp corners throw your eyes off the path of the line so you end up experiencing abrupt pauses when the line changes direction.
bevel. (redirected from Rounded corner)
You might need to use the string interpolation syntax, try this:
.border-radius (@v, @h, @radius: 5px) {
-moz-border-radius-@{v}@{h}: @radius;
-webkit-border-@{v}-@{h}-radius: @radius;
border-@{v}-@{h}-radius: @radius;
}
I would also add that webkit and mozilla are largely up to speed with the standard border-radius
property, 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:
.rounded-table(@radius) {
tr:first-child th:first-child {
-moz-border-radius-topleft: @radius;
-webkit-border-top-left-radius: @radius;
border-top-left-radius: @radius;
}
tr:first-child th:last-child {
-moz-border-radius-topright: @radius;
-webkit-border-top-right-radius: @radius;
border-top-right-radius: @radius;
}
tr:last-child td:first-child {
-moz-border-radius-bottomleft: @radius;
-webkit-border-bottom-left-radius: @radius;
border-bottom-left-radius: @radius;
}
tr:last-child td:last-child {
-moz-border-radius-bottomright: @radius;
-webkit-border-bottom-right-radius: @radius;
border-bottom-right-radius: @radius;
}
}
Usage:
.greytable {
.rounded-table(10px)
}
Output:
.greytable tr:first-child th:first-child {
-moz-border-radius-topleft: 10px;
-webkit-border-top-left-radius: 10px;
border-top-left-radius: 10px;
}
.greytable tr:first-child th:last-child {
-moz-border-radius-topright: 10px;
-webkit-border-top-right-radius: 10px;
border-top-right-radius: 10px;
}
.greytable tr:last-child td:first-child {
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.greytable tr:last-child td:last-child {
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
border-bottom-right-radius: 10px;
}
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