当然有一种方法可以在LESS中重写以下内容?
#bg-slider{ li:nth-child(1){ background:url('../images/bg1.jpg'); } li:nth-child(2){ background:url('../images/bg2.jpg'); } li:nth-child(3){ background:url('../images/bg3.jpg'); } }
我试过了:
.bg-image (@slide) { background:url('../images/bg@{slide}.jpg'); } #bg-slider{ li:nth-child(n){ .bg-image(n); } }
但这只是给所有李的'../images/bgn.jpg'.
#bg-slider { li { .bkg(1); .bkg(2); .bkg(3); } .bkg(@i) { &:nth-child(@{i}) { background: url('../images/bg@{i}.jpg'); } } }