This article mainly introduces the method of using JS to solve the problem that IE6 does not support max-width,max-height. Need friends can come to the reference, I hope to help you.
Today encountered a problem with JS to solve IE6 support max-width,max-height, just started with the jquery method to achieve, but has been not to get the value of CSS, such as code as follows: if ($. Browser.msie && $.browser.version = = 6.0) { var maxwidth = parseint ($ ('. Viewbigpic img '). CSS ( ' Max-width ')); $ ('. Viewbigpic img '). each (function () { if ($ (this). Width () > maxwidth) $ (this). Width (maxwidth); }); } Do not know what the reason is not to get the maximum value in the CSS, and then only use the original JS to achieve JS code as follows: code as follows: <script type= ' Text/javascript ' > function Setphotosize (elem, width, height) {<!--[if IE 6]> try{var image=new image (); image.src=elem.src; if (image . width>0 && image.height>0) {var rate = (Width/image.width < height/image.height)? width/image.width:h Eight/image.height; if (rate <= 1) {elem.width = image.width*rate; elem.height = image.height*rate;} else {elem.width = Image.width; elem. Height = image.height; }}catch (e) {} <!--[endif]--> } </SCThe HTML code for the Ript> section is as follows: code as follows: <div class= "Viewbigbox" > <DIV class= "Viewbigpic" > <p><img id= "Imgid" onload= "Setphotosize" (This, 730,470) "src=" images/viewshow.jpg "alt=" "/></p> </div> & nbsp </div> CSS style is as follows: The code is as follows:. viewbigbox{border:1px solid #e3e3e3; Background-color: #ff Ffff padding:1px; margin-top:18px;} . viewbigpic{Background-color: #f7f7f7;p adding:20px 14px; viewbigpic p{display:table-cell;width:730px; line-height : 470px; Overflow:hidden; Vertical-align:middle; Text-align:center; height:470px;*font-size:390px;} //Achieve the vertical center of the picture, mainly using the ratio of font-size and height. viewbigpic p img{vertical-align:middle; max-height:470px : 730px;}