XML technologies / ePUB / CSS essentials / Important CSS properties / Background

(Excerpt from “E-Books mit ePUB ─ Von Word zum E-Book mit XML” by Dr. Victor Wang)

The table lists the main CSS properties for backgrounds, with possible values and an example each.

background-image

Background image

Defines a background image. Depending on its size, it repeats automatically if small, or is only partially displayed.

Values

<URI> | none | inherit

Example

background-image: url(http://www.it-fachportal.de/logo.gif);

background-color

Background color

Defines the element’s background color using RGB values or the 16 color names.

Values

<Farbe> | transparent | inherit

Example

background-color: silver;

background

Background formatting

Compact notation for the background properties (background-color, background-image, background-repeat, background-attachment, background-position)

Values

[background-color || background-image || background-repeat || background-attachment || background-position] | inherit

Example

background: #2277bb;

background-position

Background image position

Only in combination with background-image. Additionally positions the image by its upper-left corner. Values may be numeric or:

1) top: vertically top-aligned

2) bottom: vertically bottom-aligned

3) center: centered

4) left: horizontally left-aligned

5) right: horizontally right-aligned

Values

[ [ <Prozent> | <Länge> | left | center | right ] [ <Prozent> | <Länge> | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit

Example

background-image: url(logo.jpg) background-position: top left;

background-attachment

Watermark effect

Adds a background image that can act like a watermark.

With the value fixed, the image remains fixed; with scroll, it scrolls with the content.

Values

scroll | fixed | inherit

Example

background-image: url(logo.jpg);

background-repeat

Background image repetition

Only in combination with background-image. Specifies how often to repeat the image. Permitted values:

1) repeat: unlimited repetition

2) repeat-x: horizontal repetition only

3) repeat-y: vertical repetition only

4) no-repeat: no repetition

Values

repeat | repeat-x | repeat-y | no-repeat | inherit

Example

background-image: url(bild.jpg) backgroundrepeat: repeat;

   

 

 

 

back to top