1.CSS background:
CSS allows you to apply a solid color as a background, and also allows you to create fairly complex effects using a background image
Properties |
Description |
Background-attachment |
Whether the background image is fixed or scrolls along with the rest of the page |
Background-color |
Set the background color of an element |
Background-image |
Set the picture to the background |
Background-position |
Set the starting position of the background picture |
Background-repeat |
Set whether and how the background picture repeats |
The properties in the table are described in the following two examples.
Example 1: Background color
Body { background-color: red;}
Example 2: Setting the background map
Body { background-image: url ("Python.png")}
You can see that the background graph shown has many Python images, because by default the background image is duplicated, and we can set the background-repeat
properties to see if the picture is repeatable. Css.css Add the following content
Body { background-image: url ("Python.png"); background-repeat: no-repeat;}
No-repeat means no repetition, repeat is repeatable, repeat-x represents x-axis repetition, repeat-y represents y-axis repetition
ackground-position
Used to set the starting position of the picture the following example places a background image from the top of the middle in the BODY element:
Body { background-image: url ("Python.png"); background-repeat: no-repeat; background-position:center top;}
There are many ways to provide a value for the Background-position property. First, you can use some keywords: top, bottom, left, right, and center. Usually, these keywords will appear in pairs, but not always. You can also use length values, such as 100px or 5cm, and finally you can use a percentage value. Different types of values have slightly different placement for background images. We do not elaborate the property values here, we need to use the time you can find on the w3school.
Background correlation If the page is longer, the background image scrolls as the page scrolls down. The image disappears when the page scrolls over the location of the image. We can background-attachment
prevent this scrolling by attributes. With this property, you can declare that the image is fixed in relation to the visible area (fixed) and therefore not affected by scrolling:
Body { background-image: url ("Python.png"); background-repeat: no-repeat; background-attachment:fixed;}
Prevent Background Map Scrolling I believe everyone is also often seen, especially some annoying ads.
2.CSS3 background
Properties |
Description |
Background-size |
Specify the size of the background image |
Background-origin |
Specify the location area of the background image |
Background-clip |
Drawing area with specified background |
We also cite the above examples to illustrate these attributes.
Body { background-image: url ("Python.png"); background-repeat: no-repeat; background-size:100px 100px;}
CSS Crash Tutorial-Introduction to Web page background--3