How to use CSS Sprites ?

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
anyone know how to use CSS Sprites to make different backgrounds in a image file ?
Thanks
 

webdesign

Well-known member
Joined
Jul 5, 2012
Messages
120
Points
0
For example you have a button with two status are normal and hover states, each state has a corresponding background. Normally you will save two files normal.gif (16x16px) and hover.gif (16x16px).
Now create a file using PS picture.gif (32x16px) then copy paste to 2 other images, the image on the left to normal, the right to hover image, like puzzle games so that.
Set CSS with code
a{
background: #FFFFFF url("picture.gif") left no-repeat;
}
a:hover{
background: #FFFFFF url("picture.gif") -16px no-repeat;
}
just simple way to make css sprites :)
 

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
Simple tip but very useful. Thanks
 

madelinekim

Member
Registered
Joined
Aug 8, 2012
Messages
26
Points
0
When you use CSS spirits you have to keep some points in mind such as CSS files are little bit heavier, Give attention when you are using repeat. For using the CSS spirits you have to put multiple files together in one file.
 

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
Thanks for all info, I've never used css sprites but now I can know abit about it
 
Older Threads
Replies
1
Views
2,623
Replies
2
Views
3,340
Replies
14
Views
6,371
Replies
19
Views
8,624
Replies
4
Views
2,976
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top