Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize images from sprite

Tags:

html

css

Is it possible to resize images which we receive from sprite. I mean like this:

background: url(../images/sprite.png) no-repeat -1px -1170px;
display: block;
height: 14px;
width: 14px;

Is it possible to change width and height from sprite? For example if I have pencil icon in sprite with resolution 40x40 but I want to display this pencil icon like 20x20 pixels

Thank you, in advance.

like image 489
Sergey Avatar asked Nov 26 '11 14:11

Sergey


3 Answers

Another solution is to use the zoom: .5; property of css3.

like image 187
zmanc Avatar answered Nov 12 '22 21:11

zmanc


You can use the background-size property in css3:

background-size: 50% 50%;
like image 24
Gregg B Avatar answered Nov 12 '22 22:11

Gregg B


Changing background-size will make you have to revalidate width and height of container every time.

When using zoom you will not have support for firefox

...

Another option is to use:

transform: scale(.5); /* 50% smaller */
transform: scale(1.5); /* 50% bigger */

The backside is that element after scaling will still keep its original space.

like image 4
Tomasz Mularczyk Avatar answered Nov 12 '22 20:11

Tomasz Mularczyk