jQuery 1.4 动态创建的图像纵横比在 IE8 和最大宽度中不正确
升级到 jQuery 1.4 后,当我尝试在 IE8 中使用 jQuery 1.4 动态地将图像添加到页面时,图像将失去正确的宽高比。这似乎只影响 IE8(IE7 和 Firefox 工作正常)和 jQuery 1.4(1.3.2 工作正常)。包含 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>
After upgrading to jQuery 1.4, when I try to add an image to a page dynamically using jQuery 1.4 in IE8, the image will lose the correct aspect ratio. This appears to affect only IE8 (IE7 and Firefox work fine) with jQuery 1.4 (1.3.2 works fine). Including the jQuery compatability file does not fix the problem.
<!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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置 CSS
zoom
属性:Set CSS
zoom
property: