Css background-size attribute, cssbackground-size

Source: Internet
Author: User

Css background-size attribute, cssbackground-size

The background-size attribute specifies the size of the background image.

Syntax
Background-size: length | percentage | cover | contain;
Length specifies the height and width of the background image.
Set the width of the first value and the height of the second value.
If only one value is set, the second value is set to "auto ".

Percentage specifies the width and height of the background image as the percentage of the parent element. Set the width of the first value and the height of the second value. If only one value is set, the second value is set to "auto ".

Cover extends the background image to a large enough size to completely overwrite the background image. Some parts of the background image may not be displayed in the background positioning area.

Contain expands the image size to the maximum size so that its width and height fully adapt to the content area.

Default Value: auto
Inheritance: no
Version: CSS3
JavaScript Syntax: object. style. backgroundSize = "60px 80px"

IE9 +, Firefox 4 +, Opera, Chrome, and Safari 5 + support the background-size attribute.

Example 1:

<! DOCTYPE html> 


Example 2:

<! DOCTYPE html> 

 


 

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.