Modernizr:如何检测 CSS display:table-cell 支持?
我想在支持它的浏览器中使用 display: table
和 display: table-cell
进行布局。在 IE7 中,我只是想浮动我的列(因为我假设它不可能在该浏览器中工作),但无法找到有关如何使用 Modernizr 执行此操作的任何信息。有人可以帮我吗?
我想我可以使用浏览器条件,但希望不必分解另一个 CSS 文件。
谢谢!
I want to use display: table
and display: table-cell
for my layout in browsers that support it. In IE7 I simply want to float my columns (since I assume it's not possible to get it to work in that browser), but cannot find anything about how to do it using Modernizr. Can anyone help me please?
I suppose I could use a browser conditional, but was hoping to not have to break out another CSS file.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只想对 IE7 及以下版本应用一个不同的规则,我会倾向于不使用 Modernizr 来完成此特定工作。
只需执行类似这样的操作,即可避免
“分解另一个 CSS 文件”
:这使用 Star Property Hack 提供仅适用于 IE7 及以下版本的规则。
另一种选择是
!ie7
hack,出于某种奇怪的原因,这是我得票最高的答案。If all you want to do is apply a single different rule for IE7 and less, I'd be tempted not to use Modernizr for this specific job.
Simply do something like this, to avoid having to
"break out another CSS file"
:This uses the Star Property Hack to provide a rule to only IE7 and below.
Another option is the
!ie7
hack, which is for some odd reason my highest voted answer....如果您想使用 Modernizr,您可以使用以下代码段:
Source [Link]
... And if you want to use Modernizr, you could use this snippet:
Source [Link]
当创建的元素是“tfoot”并且显示值为“table-header-group”时,IE 8 不会说实话。即使 IE 8 忽略 CSS 设置并继续在“tbody”下方显示“tfoot”,以下代码片段也不会失败。
这可能是“正确的”,因为“tfoot”已经将显示设置为“table-footer-group”;但它是“错误的”,因为它(a)不允许用户覆盖,并且(b)没有告诉用户它不会工作。我没有测试过其他浏览器。
IE 8 does not tell the truth when the created element is a 'tfoot', and the display value is 'table-header-group'. The following snippet will not fail, even though IE 8 ignores the CSS setting and continues to display 'tfoot' below 'tbody'.
It might be 'correct', in the sense that 'tfoot' has already set display to 'table-footer-group'; but it's 'wrong' in the sense that it (a) doesn't allow the user to override, and (b) doesn't tell the user that it isn't going to work. I haven't tested other browsers.