具有一组 div 的图像的 CSS spritesheet
我试图对一堆盒子使用精灵表,我这样做的方式显然多次调用图像(导致精灵表无用,或者实际上更糟)。只是想知道如何才能更有效地调用一次图像
<div class="live-box-outer">
<div class="live-box contact-highlight" id="phone">
<div class="overlay" style="display: none">
<h2>
Telephone Number</h2>
<div class="arrow">
</div>
</div>
<span>Our #</span>
</div>
</div>
<div class="live-box-outer">
<div class="live-box" id="mobile">
<div class="overlay" style="display: none">
<h2>
text mobile
functions</h2>
<div class="arrow">
</div>
</div>
<span>Mobile Sites</span>
</div>
</div>
以及我的风格:(这只是一个示例,我大约有 9 个盒子)
#phone
{
background-image:url('../img/Mountain.png');
background-position: 0px 0;
background-repeat:no-repeat;
}
#mobile
{
background-image:url('../img/Mountain.png');
background-position: 0px -134px;
background-repeat:no-repeat;
}
Im trying to use a spritesheet for a bunch of boxes, the way I am doing it obviously calls the image multiple times (causing the spritesheet to be useless, or actually worse). Just wondering how I can make this more efficient calling the image once
<div class="live-box-outer">
<div class="live-box contact-highlight" id="phone">
<div class="overlay" style="display: none">
<h2>
Telephone Number</h2>
<div class="arrow">
</div>
</div>
<span>Our #</span>
</div>
</div>
<div class="live-box-outer">
<div class="live-box" id="mobile">
<div class="overlay" style="display: none">
<h2>
text mobile
functions</h2>
<div class="arrow">
</div>
</div>
<span>Mobile Sites</span>
</div>
</div>
And my style: (this is just a sample, I have about 9 boxes)
#phone
{
background-image:url('../img/Mountain.png');
background-position: 0px 0;
background-repeat:no-repeat;
}
#mobile
{
background-image:url('../img/Mountain.png');
background-position: 0px -134px;
background-repeat:no-repeat;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该有效
Should work