Home > Web Front-end > JS Tutorial > body text

JS css image automatic scaling and adaptive size_javascript skills

WBOY
Release: 2016-05-16 17:26:20
Original
1491 people have browsed it

I added css restrictions:

Copy code The code is as follows:

div img {}{
max-width:600px;
width:600px;
width:expression(document.body.clientWidth>600?"600px":"auto");
overflow:hidden;
}

◎ max-width:600px; The maximum width is 600px under IE7, FF and other non-IE browsers. But it doesn't work in IE6.
 ◎ width:600px; The image size is 600px in all browsers;
◎ When the image size is larger than 600px, it will be automatically reduced to 600px. Valid in IE6.
◎ overflow:hidden; Hide the excess part to avoid stretching and deformation caused by failure to control the image size. < script language="JavaScript">
var imgObj;
for( i = 0; i < document . getElementsByTagName("img") . length; i )
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template