喜的只是一部分,如何显示的图像为背景
我有这样的代码:
input[type="checkbox"]:not(old) + label {
background: url("sprites.gif") no-repeat -220px -54px;
box-sizing: border-box;
height: 25px;
padding: 0 0 0 35px;
}
的事情是,我使用的背景图像中包含许多精灵,所以我只是想要在坐标0 -100px上显示。但是,由于标签宽度可能会有所不同(因为包含文本的长度),它还会显示我需要的精灵旁边的精灵。
如何在不编辑图像的情况下解决此问题?我只想显示25x25像素的背景图像。剩下的我不需要。身高我可以定义,但我不能宽度,因为正如我已经说过,它必须符合标签中的文字。
谢谢。
input[type="checkbox"]:not(old) + label {
background: url(http://cdn.sstatic.net/Sites/stackoverflow/../../img/share-sprite-new.svg?v=78be252218f3) no-repeat -220px -54px;
box-sizing: border-box;
height: 25px;
padding: 0 0 0 35px;
}
<input type="checkbox"><label>Some randome text</label>
你能提供一个链接到一个原型 – Terabyte
片段加入到这个问题。 –