Home  >  Article  >  Web Front-end  >  JQuery loading image adaptive fixed size DIV_javascript technique

JQuery loading image adaptive fixed size DIV_javascript technique

WBOY
WBOYOriginal
2016-05-16 17:22:541144browse

How to place an image in a fixed-size div. When the image is smaller, the actual size is displayed. When the image exceeds the size of the div, the image automatically adapts to the size of the div.

The main code for the jquery image adaptive size implementation process :

The code is as follows:

Copy the code The code is as follows:

.divImg{
max-height:200px; max-width:200px;
width: expression(this.width > 200 && this.width > this.height ? 200 : auto);
height: expression(this.height > 200 ? 200 : auto);
}

Example:

The code is as follows:
Copy code The code is as follows:





Implement adaptive image loading
< ;script type="text/javascript" src="../jquery.min.js">


< ;/head>









Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn