Fixed background images won't change with Page scrolling, and location considerations

Source: Internet
Author: User

 

Fixed background images won't change with Page scrolling, and location considerations

Body {</P> <p> background-color: # FFF; Background-image: URL (CSS/images/chatu.jpg); background-repeat: No-Repeat; background-position: Right Bottom; Background-Attachment: fixed; </P> <p >}< br/>

In addition to the following three attributes, background-color must be added,

Otherwise, the images on the imported page will appear repeatedly, and the content on the page will appear repeatedly (IE6 will appear, and this situation is especially obvious when it is opened in the Framework)

Background-image: URL (CSS/images/chatu.jpg );

Background-repeat: No-Repeat;

Background-position: Right Bottom; Background-Attachment: fixed;

For example, the original image is designed as follows:

When backgound-color is not added, it is displayed in IE6 as follows:

This is normal in IE7 and 8.

Attached hereBackground CSS learning Manual

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 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.

 

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.

 

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.