【发布时间】:2015-07-03 01:37:32
【问题描述】:
这是我过去遇到的麻烦,我一直在想,所以我制作了一个简单的示例精灵图像进行测试,希望能得到一些答案。
如果您在此处查看我的代码和演示 http://dabblet.com/gist/2263037
你会看到我有一个使用背景图片的简单 div
在该 DIV 下方我有相同的 div,但这次我尝试使用 CSS Sprite 图像代替
所以我的问题是,是否可以使用此精灵图像复制第一个 DIV 的外观,或者是否需要对精灵图像进行更改?
没有 Sprite 图片
/* Notice wrapper with Single Image */
.notice-wrap {
margin-top: 10px; padding: 0 .7em;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
border: 1px solid #CD0A0A;
background: #B81900 url(http://www.getklok.com/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat;
}
有雪碧图片
/* Notice wrapper with SPRITE Image */
.notice-wrap-sprite {
margin-top: 10px; padding: 0 .7em;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
border: 1px solid #CD0A0A;
background: #fff url(http://f.cl.ly/items/2P1u2S1a132R0B3d2s08/test-sprite.png) repeat;
background-position: 0 -52px;
}
HTML
<div class="notice-wrap">
<p><strong>NOTICE:</strong> This is just a test notice, no reason to be alarmed</p>
</div>
<BR><BR><BR>
<div class="notice-wrap-sprite">
<p><strong>NOTICE:</strong> This is just a test notice, no reason to be alarmed</p>
</div>
【问题讨论】: