如何使IE支持最小宽度/最大宽度CSS属性? [英] How to make IE support min-width / max-width CSS properties?

查看:135
本文介绍了如何使IE支持最小宽度/最大宽度CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些属性不被视为标准CSS吗?

Are these properties not considered standard CSS?

我使用类似这样的东西,可以在Chrome 12,FF4,Opera 11和Safari 5,但在IE9的最小宽度不尊重如果 width<最小宽度

I'm using something like this, which works properly on Chrome 12, FF4, Opera 11, and Safari 5, but on IE9 the min-width is not respected if width < min-width.

<span style="float:left; width:11%; min-width:150px;">
    ...
</span>






编辑:对自由编辑有点恼火迁移我的问题,但w / e。这是一个更全面的例子,显示IE9与其他浏览器的明显差异。


a little annoyed at the liberal editing and migrating of my question, but w/e. Here's a fuller example that shows a clear difference in IE9 vs other browsers.

<html><body>
<p style="width: 600px">
<span style="float: left; width: 11%; min-width: 150px">Hello.</span>
<span style="float: left; width: 11%">World.</span>
</p>
</body></html>






编辑2:将<!DOCTYPE html> 添加到开头解决了IE问题。


Edit 2: As noted in Kevin's comment below, adding <!DOCTYPE html> to the beginning solves the IE issue.

推荐答案

如果您所说的是真的,IE9会偏离规范 a>。但是,我无法复制您的投诉。使用你的例子,IE9尊重 min-width if width 小于 150px this jsfiddle

If what you are saying is true, IE9 would be deviating form the spec. However, I cannot duplicate your complaint. Using your example, IE9 respects min-width if width is less than 150px per this jsfiddle.

编辑:

注意:Quirks模式遵循不同的规则,不符合任何浏览器中的标准CSS。如果您向网页添加了一个doctype,这应该解决问题(添加:<!DOCTYPE html> )。

NOTE: Quirks Mode follow different rules and does not comply with standard CSS in any browser. If you add a doctype to the page, this should resolve the problem (add: <!DOCTYPE html>).

要解决这个问题,Quirks模式不是标准化的。有些事情是最常用的浏览器实现的,但是新功能在这些defacto标准中未定义。因此,一些浏览器允许使用新的CSS(如你所观察到的),但IE9会忽略新的css值,因为它们在Quirks模式下没有地方。

To expand on the issue, Quirks Mode is not standardized. There are some things that most browser implement, but new features are undefined in those defacto standards. Thus, some browsers are allowing new CSS to be used (as you have observed), but IE9 is ignoring new css values, as they have no place in Quirks Mode.

这篇关于如何使IE支持最小宽度/最大宽度CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆