生成CSS精靈效果所需的代碼的回覆似乎是使用LESS的最佳例子。用LESS減少sprite CSS?
但是除了標準化基礎,懸停和活動增量(下面),我看不到任何進一步的方式來減少所需的代碼行。
任何人都可以提出改進futher:
@sprite-base:0px;
@sprite-hover:20px;
@sprite-active:40px;
.zone-user .region-user-second ul.text-size li.one a {
background: url("../img/sprite-accessibility.gif") no-repeat scroll 0px @sprite-base transparent;
}
.zone-user .region-user-second ul.text-size li.two a {
background: url("../img/sprite-accessibility.gif") no-repeat scroll -25px @sprite-base transparent;
}
etc ...
.zone-user .region-user-second ul.text-size li.one a:hover {
background: url("../img/sprite-accessibility.gif") no-repeat scroll 0px @sprite-base - @sprite-hover transparent;
}
.zone-user .region-user-second ul.text-size li.two a:hover {
background: url("../img/sprite-accessibility.gif") no-repeat scroll -25px @sprite-base - @sprite-hover transparent;
}
.zone-user .region-user-second ul.text-size li.one a.active {
background: url("../img/sprite-accessibility.gif") no-repeat scroll 0px @sprite-base - @sprite-active transparent;
}
.zone-user .region-user-second ul.text-size li.two a.active {
background: url("../img/sprite-accessibility.gif") no-repeat scroll -25px @sprite-base - @sprite-active transparent;
}
etc ...