Home  >  Article  >  Web Front-end  >  JS css image automatic scaling and adaptive size_javascript skills

JS css image automatic scaling and adaptive size_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:26:201485browse

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 )
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