jquery solves the problem of IE6 in the image, resulting in a dislocation solution

Source: Internet
Author: User

jquery solves the problem of IE6 in the image, resulting in a dislocation solution

Under Jqurey control in the product presentation page:

/* This label calls the product picture * *

<asp Tutorial: Image runat= "server" id= "productbigimg"/>


First introduce jquery

<script src= "/utility/js/jquery.js" type= "text/Web Effects" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#<%=productbigimg.clientid%>"). each (function () {
var maxwidth = 680; The maximum width of the picture, this number depends on the specific width of the product picture display. (In fact, to encapsulate this method,

Width as a parameter passing would be better, lazy, did not do:)
var ratio = 0; Scaling ratio
var width = $ (this). width (); Picture actual width
var height = $ (this). Height (); Picture actual height
Check if the picture is very wide
if (Width > maxwidth) {
Ratio = Maxwidth/width; Calculate zoom ratio
$ (this). CSS Tutorial ("width", maxwidth); Set the actual display width
Height = height * ratio; Calculate the height after equal scale scaling
$ (this). CSS ("height", height); Set the height of equal scale after scaling
}
});
});
</script>


Through this processing, the picture will be equal to the proportion of shrinking, in the IE6 will not be misplaced

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.