是否可以将 CSS sprites 用于列表背景图像?通常,我会像这样使用 CSS 渲染 Sprite :
.sprite { background: url(sprite.png) no-repeat top left;}
.sprite-checkmark { background-position: 0 -24px; width: 24px; height: 23px; }
.sprite-comment { background-position: 0 -48px; width: 14px; height: 14px; }
<div class="sprite sprite-checkmark"></div>
是否可以为
谢谢。
最佳答案
你也可以使用
li:before {
background:url(..) no-repeat -##px -##px;
width:##px;
height:##px;
display:block;
position:absolute;
content: " ";
top:##px;
left:##px;
}
然后将一个额外的元素添加到 DOM 中并为其提供背景图像。
关于html - 将 CSS sprites 用于列表 (<li>) 背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2381789/