[英]Using background-position with background-repeat for a CSS sprite
Here is the demo , and here is the sprite: 这是演示 ,这是子画面:
I want to use the arrow in a markup, like this: 我想在标记中使用箭头,如下所示:
<div class="tooltip">
The tooltip
<span class="arrow"></span>
</div>
Setting: 设置:
background-image: url(foobar.gif);
background-position: 0 -40px;
background-repeat: none;
does not seem to work (as expected). 似乎不起作用(按预期方式)。 Any workaround?
任何解决方法?
Do you mean: 你的意思是:
background-repeat:no-repeat
? background-repeat:no-repeat
?
Use height and width exactly.. 准确使用高度和宽度。
for example, 例如,
background-position: 0 -40px;
background-repeat: no-repeat;
height:32px;
width:32px;
or use the sprites generators online and they will render both images and css.. 或在线使用精灵生成器,它们将同时渲染图像和CSS。
eg: http://spritegen.website-performance.org/ 例如: http : //spritegen.website-performance.org/
hm try this: 嗯试试这个:
background: url(foobar.gif) 0 -40px no-repeat transparent;
should be work. 应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.