Sprite 的缩放

icon.png  大小为:27*237

假设,我们要获取到 放大境 这个图标,在大图(icon.png)中的坐标为:0,-197。width:11px; height:12px;

如果要截取原图大小,在css中代码如下:

.sprite { background: url('imgs/icon.png') no-repeat 0 -197px; width: 11px; height: 12px; }

如果要对放大镜这个图标进行缩放,假如放大一倍,代码如下:

.sprite{background: url('imgs/icon.png') no-repeat 0 -394px; background-size: 54px 474px; width: 22px; height: 24px;}
 
相应的对个参数乘2;其中backgroun-size为大图的尺寸。
 
 

猜你喜欢

转载自www.cnblogs.com/jingzeng/p/9577687.html