Today I encountered a problem about using JS to solve IE6 without supporting Max-Width, MAX-Height. I just started to implement it with the jQuery method, but I have not obtained the value in the CSS, such as such as the value of CSS, such as such as the value of CSS, such as such as the value of CSS, such as such as the value of CSS, such as such as the value of CSS, such as such as the value of CSS, such as such as the value of CSS. For example,
Copy code 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);
});
}
I don’t know why, I can't get the maximum value in the CSS, and then I can only use the native JS to achieve
JS code is as follows:
Copy code 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: head/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]->
}
</script>
The html code of the part is as follows:
Copy code code as follows:
<div>
<div>
<p> <img ID = "IMGID" Online = "Setphotosize (this, 730, 470)" SRC = "Images/ViewShow.jpg"/> </p>
</div>
</div>
The CSS style is as follows:
Copy code code as follows:
.ViewbigBox {border: 1px solid #e3e3e3; background-color: #ffffff; padding: 1px; margin-top: 18px;}
. ViewBigpic {background-color:#f7f7f7; padding: 20px 14px;}
. ViewBigpic P {Display: Table-Cell; Width: 730px; Line-Height: 470px; Overflow: Hidden; Vertical-Align: Middle; Text-Align: CENTER; 4 70px;*font-size: 390px;}
// Implement the vertical outering of the picture, mainly using the proportion of FONT-SIZE to Height
. ViewBigpic P IMG {vertical-align: middle; max-height: 470px; max-width: 730px;}