3

升级到 jQuery 1.4 后,当我尝试在 IE8 中使用 jQuery 1.4 动态地将图像添加到页面时,图像将失去正确的纵横比。这似乎只影响带有 jQ​​uery 1.4(1.3.2 工作正常)的 IE8(IE7 和 Firefox 工作正常)。包含 jQuery 兼容性文件并不能解决问题。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" language="javascript"
        type="text/javascript"></script>
    <!-- Switching to 1.3.2 fixes the problem -->
    <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" language="javascript"
        type="text/javascript"></script>-->
    <script type="text/javascript">
        $(document).ready(function() {
            var dynImg = $('<img></img>').attr('src', 'http://www.google.com/intl/en_ALL/images/logo.gif');
            $('body').append(dynImg);
        });
    </script>
    <style type="text/css">
        img
        {
            max-width: 5em;
        }
    </style>
</head>
<body></body></html>
4

1 回答 1

0

设置 CSSzoom属性:

img {
    zoom: 100%;
}
于 2010-02-16T16:01:03.913 回答