A thorough study of CSS background attributes

Source: Internet
Author: User

☆Background-color)
This attribute sets the background color for the HTML element, which is equivalent to the bgcolor attribute in HTML.
Body {background-color: #99ff00 ;}
The above Code indicates that the background color of the HTML element "body" is green.

☆Background-Image)
This attribute sets the background image for the HTML element, which is equivalent to the background attribute in HTML.
<Body style = "background-image: URL (../images/css_tutorials/background.jpg)">
The above Code sets a background image for the HTML element of the body.

☆Background-repeat)
This attribute is used together with the background-image attribute to determine whether the background image is repeated. If only the background-image attribute is set and the background-repeat attribute is not set, the image is repeated horizontally and vertically by default.
· Repeat-x duplicate background image
· Repeat-y vertical repetition of the background image
· No-repeat background images are not repeated
Body {background-image: URL (../images/css_tutorials/background.jpg); background-repeat: Repeat-y}
The above Code indicates that the image is repeated vertically.

☆Background-Attachment)
This attribute is used together with the background-image attribute to determine whether the image is scrolling with the content or not. This attribute has two values: Scroll and fixed. The default value is scroll.
Body {background-image: URL (../images/css_tutorials/background.jpg); background-repeat: No-Repeat; Background-Attachment: Fixed}
The code above indicates that the image remains unchanged and does not scroll with the content.

☆Background-Position)
This attribute is used together with the background-image attribute to determine the initial position of the background image.
Body {background-image: URL (../images/css_tutorials/background.jpg); background-repeat: No-Repeat; Background-position: 20px 60px}
The above Code indicates that the initial position of the background image is 20 Px to the leftmost side of the webpage and 60 Px to the top of the webpage.
At the end of the Code, background-position has two options: Top and left. It can be used independently or in combination as in this example.
Top: Top
Bottom: Bottom
Left: left
Right: Right
Top left: upper left
Top right: upper right corner
Right Bottom: bottom right corner
Left Bottom: lower left

☆Background)
This attribute is a quick and comprehensive method for setting background-related attributes, including background-color, background-image, background-repeat, backgroundattachment, and background-position.
Body {Background: #99ff00 URL (../images/css_tutorials/background.jpg) No-repeat fixed 40px 100px}
The webpage's background color is green, and the background image is a background.jpg image. The background image is not repeatedly displayed, and the background image does not scroll with the content. The background image is 40 Px to the left of the webpage and PX to the top of the webpage.

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.