CSS conditional Scaling

Source: Internet
Author: User

This problem occurs when helping a friend get a website.

Solution:

Reference: Use CSS to scale the image (this is similar to an endless loop when IE6 is run. The difference is that auto is used and this. width is used)

CSS code compatible with IE and Firefox scaling by Image Width

The specific method is:

IMG {  
Max-Width : 500px ;  
Height : Auto ;  
Width : Expression (this. width> 500? "500px": This. width) ;
}

Firefox uses max-width to limit the maximum width. Because IE does not know Max-width, expression is used to control the width.

 

 

Attached JS solution:

Reference: auto scaling of images in ASP (recommended)

The above JSCodeNo.

JS implementation is relatively simple, but difficult to write. CSS is convenient, concise, and flexible.

 

Appendix: When solving this problem, I thought about getting the image size first and then determining it based on the size.

There are some ways to get the size on the Internet (ASP code): use ASP to get the image size (using ADODB. Stream)

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.