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 aboveCodeThe background color of the HTML element "body" is green.
Demo
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.
Demo
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 the background image is repeated horizontally.
- 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.
Demo
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.
Demo
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.
Demo
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.