CSS background picture Auto Scale instance

Source: Internet
Author: User


By default, background properties are tiled, and if the background picture is larger and box is small, you can only display the background in the upper-left corner. If you want the background to be all displayed,

The code is as follows Copy Code

. color_checked {
Float:right;
width:16px;
height:16px;
Background:url (.. /images/color_check.png) Center 0 no-repeat;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
Background-size:cover;
}

If you still want the picture to be scaled automatically

The code is as follows Copy Code


#blogcon img {max-width:400px max-height:400px; width:expression (this.width>400 && this.width> This.height? 400:true); Height:expression (This.height > 400:true); }

The meaning of this passage is explained: The maximum width of the IMG label for all images below the ID Blogcon label is set to 400px, the maximum height is 400px, and the width is scaled proportionally if the picture width and height are greater than 400.

Original from: Application Development Notes

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.