Javascript + css Image Auto scaling adaptive size _ javascript tips-JS tutorial

Source: Internet
Author: User
The size of the image uploaded by the editor is too large, and FF and IE are removed. Therefore, we hope that the image will have a fixed size in some pages. If you need a certain range, use getElementByname to set it, also, I added css restrictions:

The Code is as follows:


P img {}{
Max-width: 600px;
Width: 600px;
Width: expression (document. body. clientWidth> 600? "600px": "auto ");
Overflow: hidden;
}


◎ Max-width: 600px; the maximum width of other non-ie browsers, such as IE7 and FF, is 600px. However, it is invalid in IE6.
◎ Width: 600px; the image size in all browsers is 600px;
◎ When the image size is greater than 600px, it is automatically reduced to 600px. Valid in IE6.
◎ Overflow: hidden; hide the excess part to avoid opening deformation caused by failed image size control.
Added

The Code is as follows:


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.