Summary of background background properties used in CSS

Source: Internet
Author: User
backgroundThe Background property is an important attribute in CSS. Use the Background property to set the various styles of a background element, including the color that sets the fill background, use your own picture as the background, and let the picture repeat horizontally and vertically until the entire element is covered, controlling the position of the background image in the element, and so on. Use picture as background in a page layout often encounter, general set object picture as Background property instances, first set the background color immediately after setting the picture as the background immediately after the picture is repeated and then with the picture in the object position. The background color of the front can not be set at the same time is not necessary, general use of the picture as the object background if you want to set the picture to repeat the distance location will set the picture position. The following is a detailed description of the various uses of the background background property.

First, you can learn the free course of PHP Chinese network.

1. Learn the CSS Background Chapter course in the CSS 0 Basics Primer Tutorial

2. Watch the background and margin video courses in the Dark Horse Programmer's CSS video tutorial

Background Background Properties

1. Must master the CSS Knowledge-background property

When we set the border for the body, we will find that border just circled the body where there is content. However, setting the background color for the body fills the entire screen.

When using an image as a background, the image is positioned as a visual area of the screen, rather than as part of the border box.

Each parameter is separated by a space, followed by a color, a picture, a repetition, a fixed way, a position.

2. Background related properties in CSS

Percent/length: If it is a percentage, the size of the background map is the product of the container multiplied by the percentage. Set only one, and the second is auto (to maintain the same length-to-width ratio as the original background map).

If both are set to 100%, the background map fills the container, but the length-to-width ratio changes.

Contain: The container contains the entire background map as a fixed proportion of the background graph. The size of the background map is enlarged by a fixed scale in the background map, and any one of its edges reaches the boundaries of the container, often leading to the other side blank (with No-repeat).

Cover: The background image is enlarged by a fixed aspect ratio to fill the entire container (the side that is shorter on the background map also reaches the container boundary). A portion of the background map is removed from the container.

3. Detailed CSS Background background properties

In the same element, the background compound attribute is written in front, and the background property that needs to be set is written at the very back; Reason: The Yangtze River before the wave, before the wave died on the beach

Multiple background graphs are added to the same element, and other background properties can only be written separately, and cannot be shortened with compound attributes;

In nested parent-child elements, it is not recommended to write a property of the same name. Reason: When the child element size is greater than or equal to the parent element size, the style of the parent element is overwritten by the quilt element;

In the actual work, multi-use background map, less to insert pictures.

4. CSS3 on the new background series background

Border-box: Ignore the border, directly from the beginning of the border 0, 0 o'clock Tile padding-box: Default, ignore padding, directly from the padding start 0, 0 o'clock Tile Content-box: Starting from the Content section tile, The location of the padding will be reserved. So padding's going to affect it.

5. How to set CSS background background and background colors in Web pages

CSS background This refers to setting the background properties of the object through CSS, such as the various styles of setting the background through CSS in a Web page.

CSS Background background: Sets the solid color background. Background background You can set the background color of the object's solid color and set the picture as the background. You can set the object background as a picture, if the background is a picture, you can let the picture repeat the tiling, or the picture as the object background fixed to the object anywhere.

6. CSS background properties and CSS3 background picture settings summary sharing

Background setting all background properties in a declaration

Background-attachment sets whether the background image is fixed or scrolls along with the rest of the page

Background-color setting the background color of an element

Background-image setting the background image of an element

Background-position setting the starting position of the background image

Related questions

1. How to accelerate the loading speed of CSS background pictures

2. Can iOS not use Background:unset? What do you want to do to cancel the background color?

3. Background position of body

"Recommended"

1. PHP Chinese Web free Tutorial: CSS online Manual

2. PHP free Video tutorial: "Learn HTML video tutorial in the blink of an finger"

3. PHP Chinese Web free video tutorial: "Php.cn lonely Nine Cheap (2)-css video Tutorial"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.