如何使用纯 CSS 自动调整图像大小以实现响应式设计?
我尝试使用 CSS 属性 max-width
自动调整图像大小,但它在 IE7 和 IE8 中不起作用。有没有办法在 IE7 和 IE8 中使用纯 CSS 自动调整图像大小?
I have tried to auto resize the image using the CSS property max-width
, but it does't work in IE7 and IE8. Is there any way to auto resize the image with pure CSS in IE7 and IE8?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
尝试这样的事情:
来源(值得一看)
Try something like this:
Source (worth taking a look at)
您需要一个适用于 IE 6-7 的一次性缓存表达式。
示例: http://kizu.ru/lib/ie/minmax.html
JS源文件:http://kizu.ru/lib/ie/ie.js
作者:罗曼·科马罗夫
You need a one-time cached expression for IE 6-7.
Example: http://kizu.ru/lib/ie/minmax.html
JS source file: http://kizu.ru/lib/ie/ie.js
Author: Roman Komarov
IE 7 和 8 不识别以下内容:
Doesn't IE 7&8 recognise the following:
大多数 Web 开发人员都知道 IE 在标准竞争和展示最新、最好的内容方面已经落后了。许多 CSS2 属性不受支持。一些更有用的属性包括 max-width、max-height、min-width 和 min-height。
试试这个:
Most web-developers know that IE has fallen behind in the race for standards and being able to show the latest and greatest. Many CSS2 properties are unsupported. Some of the more useful ones, are properties such as max-width, max-height, min-width and finally min-height.
Try this:
对于 IE8,使用
max-width: 100%
和height:auto
,加上width:auto
:Use
max-width: 100%
withheight:auto
, pluswidth:auto
for IE8:由于您还希望支持媒体查询..您可以使用以下polyfill 向 IE6-IE8 添加对媒体查询的支持
https ://github.com/scottjehl/Respond(大小非常小,压缩和压缩后只有 1-2kb)
然后使用以下CSS:
As you also want support for media queries..You can use the following polyfill to add support for media queries to IE6-IE8
https://github.com/scottjehl/Respond (very small in size, just 1-2kb minified and gzipped)
then use the following css:
我测试了它并适用于每个浏览器
I tested it and working for every browser
使用
width:inherit;
使其在 IE8 中与纯 CSS 一起使用。(请参阅 responsive-base.css。)像这样:
我不确定这是否适用于 IE7,请对其进行测试并告知我们您是否正在测试 IE7。在我弄清楚
width:inherit
技术之前,我使用了下面的 jQuery,所以如果您确实需要支持 IE7 并且第一种技术不起作用,您可以尝试一下:Use
width: inherit;
to make it work with pure CSS in IE8.(See responsive-base.css.) Like this:
I'm not sure if that works in IE7—please test it and let us know if you're testing IE7. Before I figured out the
width: inherit
technique I was using the jQuery below, so you could try it if you really need support down to IE7 and the first technique doesn't work: