Four css Image proportional scaling instances (compatible with ie6, 7, and firefox)

Source: Internet
Author: User

Use the css attributes of max-width, max-height; or min-width and min-height. For example:

The code is as follows: Copy code
Img {max-width: 100px; max-height: 100px ;}
Img {min-width: 100px; min-height: 100px ;}


For browsers of ie6 and earlier versions, you can use the expression attribute supported by ie6 to embed the webpage special effect code in css code.
To scale the image.

. Thumbimage {max-width: 100px; max-height: 100px;}/* for firefox & ie7 */
* Html. thumbimage {/* for ie6 */
Width: expression (this. width> 100 & this. width> this. height? 100: auto );
Height: expression (this. height> 100? 100: auto );
}


Method 2

Proportional scaling of css images
Css Image proportional scaling.

The code is as follows: Copy code
Thumbimaged {max-width: Pixel px; max-height: Pixel px;}/* for firefox & ie7 */* html. thumbimaged {/* for ie6 */width: expression (this. width & gt; 650 & this. width> this. height

Method 3

<Style type = "text/css">

The code is as follows: Copy code
. Thumbimage {
Max-width: 300px;
Max-height: 200px;
}
* Html. thumbimage {
Width: expression_r (this. width> 300 & this. width> this. height? 300: auto );
Height: expresion (this. height> 200? 200: auto );
}

</Style>

Call this css style in image call
------------------------------------------


Method Example 4

The code is as follows: Copy code
# Image1 {
Width: expression (this. width> 980 & this. width> this. height? 730: true );
Height: expresion (this. height> 980? 730: true );
}


If the image width exceeds 980, go to 980, less than 980, and take the original width

 

 

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.