我有顯示的背景圖像的一類:遞增背景圖像ID與薩斯
@media all and (min-width: 31.25em) {
.switch-image {
display:block;
background-image: url(/asset/img/img-1.png);
background-repeat: no-repeat;
background-position: center;
}
}
我的問題是,我有大約30的圖像(img-1.png
到img-30.png
)
如何能我省了不用寫上面30次。
我可以通過上述循環並增加panel-1
1
所以panel-2
?
你能舉一個HTML的小例子嗎?所有30個元素是否有相同的類(第一個元素將獲得img-2,第二個img-2 ...)或不同的類('panel-1','panel-2')? – nishantjr 2014-09-22 12:09:19
@nishantjr - HTML的例子可以在這裏找到:http://scheckoverflow.com/questions/25972274/css-image-swapping-removing-duplicated-code/25972502?noredirect=1#comment40667507_25972502 – 2014-09-22 12:11:28