Web standardization: Using CSS to zoom in on a picture

Source: Internet
Author: User
Tags expression
Css|web|web Standard

Of course, to generate thumbnails of this work if the program to complete, the effect will be much better, but sometimes for some reason, such as the server does not support GD and so on, it is inevitable to ask for CSS.

To reduce a large picture proportionally to a certain size, for modern browsers, use the Max-width and max-height two CSS properties directly.

For IE 6.0 and the following version, the above two CSS properties will not be ignored. Before dealing with this sort of thing, we tend to use JavaScript and then add the OnLoad event to the picture. For example:


This can solve the problem, but for the next page upgrade will bring trouble-with the browser to the CSS support, we will sooner or later the OnLoad event on the picture removed. It's time for expression's show, and since IE supports placing scripts in CSS via expression, and this script is only available to IE 6.0 and the following versions, it would be appropriate to write it in expression.

Finally, a pair of large pictures in proportion to 50px*50px, you can refer to the following CSS:

. thumbimage {
max-width:50px;
max-height:50px;
}
* HTML. Thumbimage {
Width:expression (This.width > && this.width > This.height 50:auto);
Height:expresion (This.height > 50:auto);
}

As for how the picture maintains its high and wide proportions, this picture can explain:



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.