Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Get background image from a image file by position in CSS

Get background image from a image file by position in CSS

Problem

We suppose that we have the following image (is a single file with 4 radio buttons, seems same but it is for example, the Icons could be different):

I saw, a time ago, how to get an image by specifing Background-position in CSS style. How to do that ?

Means, how to get the icon from lower-right side in CSS instead splitting that file in four icons separately ?

Sorry if this question is obsolete but I'm beginner in CSS.

Problem courtesy of: Snake Eyes

Solution

Have a look at the background-position attribute.

MDN has an article about it, including examples.

There are also a number of articles available about image-sprites with CSS.

Solution courtesy of: Christofer Eliasson

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Get background image from a image file by position in CSS

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×