html – 如何使用纯CSS自动调整图像的响应设计?

我试图使用CSS属性max-width自动调整图像大小,但它不能在IE7和IE8中运行.有没有办法在IE7和IE8中使用纯CSS自动调整图像大小?

解决方法

使用width:inherit;使其在IE8中使用纯CSS.
(见 responsive-base.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,请告诉我们.在我弄清楚宽度之前:继承技术我正在使用下面的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]-->

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些