html – 如何使用纯CSS自动调整图像的响应设计?
发布时间:2020-12-14 18:59:40 所属栏目:资源 来源:网络整理
导读:我试图使用CSS属性max-width自动调整图像大小,但它不能在IE7和IE8中运行.有没有办法在IE7和IE8中使用纯CSS自动调整图像大小? 解决方法 使用width:inherit;使其在IE8中使用纯CSS. (见 responsive-base.css.)像这样: img { width: inherit; /* This makes t
我试图使用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]--> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |