CSS Background Instance

Source: Internet
Author: User

1. Setting the background color

Background-color:yellowbackground-color: #00ff00background-color:rgb (250,0,255)

2. Set the image to the background

Background-image:url (/images/.jpg);

3. Repeat background image

Background-image:url (); Background-repeat:repeat;background-repeat:repeat-x;background-repeat: Repeat-ybackground-repeat:no-repeat

3. Place the background image on the page

Background-position:centerbackground-attachment:fixed

You need to set the Background-attachment property to "fixed" to ensure that the property works correctly in Firefox and Opera.

4. Use percentages to position the background image on the page

Background-image:url ('/i/eg_bg_03.gif '); background-repeat:no-repeat;background-attachment:fixed; background-position:30% 20%

In order to achieve this effect in Mozilla, the Background-attachment property must be set to "fixed".

Use image to position background image on page

background-position:50px 100px;

5. Use the shorthand attribute to set all background properties in one declaration

Background: #ff0000 URL (/i/eg_bg_03.gif) no-repeat Fixed Center;

CSS Background Instance

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.