CSS background Image Properties background

Source: Internet
Author: User
Tags transparent color

The CSS background attribute "Background" provides many attribute values, such as color, image, positioning, etc., which provides a great convenience for the definition of Web page background image. Look at the property values provided by background:

Background:background-color background-image background-repeat background-attachment background-position

From the name of the attribute value can be very clear to see, is: color, image, layout, scrolling, positioning, where background-repeat, background-position must be in the specified Background-image attribute value only valid.

Background-color:transparent color. "Transparent" is the default property value for Background-color (the red Word indicates the default value), meaning the background color is transparent, that is, no background color, and "color" refers to the color, can be HTML language support English words, can also be hexadecimal color values, Of course, it is recommended to use hexadecimal color values, such as black to use "#000."

Background-image:none URL. The default property value is a no background image, which you need to import using a background map.

Background-repeat:repeat no-repeat repeat-x repeat-y. The default property value is that the background image is tiled vertically and horizontally, using "no-repeat" if you do not want the image to be tiled but with a complete lining, and the same principle is tiled horizontally using the "repeat-x" tile using "repeat-y".

Background-attachment:scroll fixed. "Scroll" is the background image with the content scrolling, "fixed" is the background image fixed.

Background-position:position (length) position (length). There are two ways to choose the background image position of an object, one is to use position (top center bottom left center right) to locate the background image, and the other is to use Lefgth (numeric) to locate, and the value should be noted , when there is only a numerical value, the values will be used for the horizontal axis, the ordinate will default to be 50%, if there are two values, the horizontal axis, ordinate.

After understanding and familiar with the above background attributes and attribute values, it is easy to make appropriate processing for the background image of the Web page. But here's a trick: after defining the Background-image attribute, you should define a Background-color value that is similar to the color of the background image, so that when the slow speed background image is not loaded or the background image is lost, can still provide good text recognition. For example, the background image is a black bottom map, then the color of the text will naturally choose a light tone or even white, if the background image is not loaded or the image is lost, then you need to define a black background color, you can keep the text of the recognition.

Related Article

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.