Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Multiple images in one and using CSS to determine a background

Tags:

css

trim

If you don't know what I mean, check this image out:

Multiple images

I want to know how it works, CSS yes, but exactly how does it all work out when using a background using this image and then it is all cut all exactly what it is supposed to do - when determined as a background for this image.

Would be interesting for me to know how - so I can take my CSS level up a bit more :P

Thanks

like image 587
MacMac Avatar asked Mar 11 '10 10:03

MacMac


People also ask

How do you put multiple images as your background in CSS?

CSS allows you to add multiple background images for an element, through the background-image property. The different background images are separated by commas, and the images are stacked on top of each other, where the first image is closest to the viewer.

How do I combine background and image images in CSS?

Use background-blend-mode and rgba to mix the background image and color. If you adjust the alpha value of the rgba color value (it's at . 85 in the example), you can control the transparency. Also, background-blend-mode has other values you can play with to get some really creative results.

What CSS property sets one or more background images on an element?

The background-image CSS property sets one or more background images on an element.

How would you set multiple background images to an element using a single class?

The multiple background images for an element can be put in the HTML page using CSS. Use CSS background property to add multiple background images for an element in any pattern and use other CSS property to set the height and width of the images.


2 Answers

What you are looking for is CSS Sprites, there are heaps of tutorials and ways to achieve this. Basically what you are doing is declaring a background and using background-position to decide what in the background is displayed.

CSS Sprites are great by the way, good job for trying to figure them out.

like image 179
Sam152 Avatar answered Sep 19 '22 00:09

Sam152


{
    height: foo;
    width: foo;
    overflow: hidden;
    background: colour url() no-repeat 0 pixels-to-top-of-image;
}
like image 43
Quentin Avatar answered Sep 18 '22 00:09

Quentin