XML technologies / CSS / CSS Cookbook / Images / Non-repeating background images

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

You want to use a background image without repeating it.

Solution

Use the properties background-image and background-repeat to control the background image’s display (see the next figure):

body {
 background-image: url(bkgd.jpg);
 background-repeat: no-repeat;
}

The background image appears only once in the top-left corner

Figure: The background image appears only once in the top-left corner.

Discussion

You can place text and other embedded images over a background image to give a web page a sense of depth. Repeating the image along the edges of the browser window, on the other hand, can give a web page a frame.

See also

The recipe Repeating background images for repeating background images vertically or horizontally.

  

 

 

 

back to top