我尝试使用 CSS 属性自动调整图像大小max-width
,但它在 IE7 和 IE8 中不起作用。有没有办法在 IE7 和 IE8 中使用纯 CSS 自动调整图像大小?
Use width: inherit;
使其能够在 IE8 中使用纯 CSS。
(看响应式基础.css https://github.com/ryanve/css3base/blob/master/responsive.css。) 像这样:
img {
width: inherit; /* This makes the next two lines work in IE8. */
max-width: 100%; /* Add !important if needed. */
height: auto; /* Add !important if needed. */
}
我不确定这是否适用于 IE7,请对其进行测试并告知我们您是否正在测试 IE7。在我弄清楚之前width: inherit
我使用的是下面的 jQuery,所以如果您确实需要 IE7 的支持并且第一种技术不起作用,您可以尝试一下:
<!--[if lt IE 9]><script>
jQuery(function($) {
$('img').each(function(){
// .removeAttr supports SSVs in jQuery 1.7+
$(this).removeAttr('width height');
});
});
</script><![endif]-->
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)