Stylus支持通過使用{}字符包圍表達(dá)式來插入值,其會(huì)變成標(biāo)識(shí)符的一部分。例如,-webkit-{'border' + '-radius'}等同于-webkit-border-radius.
比較好的例子就是私有前綴屬性擴(kuò)展:
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
{prop} args
border-radius()
vendor('border-radius', arguments)
box-shadow()
vendor('box-shadow', arguments)
button
border-radius 1px 2px / 3px 4px
變身:
button {
-webkit-border-radius: 1px 2px / 3px 4px;
-moz-border-radius: 1px 2px / 3px 4px;
border-radius: 1px 2px / 3px 4px;
}
插值也可以在選擇器上起作用。例如,我們可以指定表格前5行的高度,如下:
table
for row in 1 2 3 4 5
tr:nth-child({row})
height: 10px * row
也就是:
table tr:nth-child(1) {
height: 10px;
}
table tr:nth-child(2) {
height: 20px;
}
table tr:nth-child(3) {
height: 30px;
}
table tr:nth-child(4) {
height: 40px;
}
table tr:nth-child(5) {
height: 50px;
}
更多建議: