css - 使用#IEroot 进行针对 ie 的样式?

标签 css internet-explorer

有没有人能够成功使用 IE CSS hack #IEroot?我是从 this article 偶然发现的但它似乎对我不起作用。

我正在尝试修复/破解内联样式错误以生成 li 内联 block

#featured li {
    margin:0px;
    padding:0px;
    width:317px;
    height:310px;
    display:inline-block;
    border-left:1px #bdbdbd solid;
}
#IEroot #featured li {
    display:inline;
}

非常感谢任何帮助,谢谢。

最佳答案

它确实有效,与描述的完全一样,即使在 IE8 中也是如此,并且实际上是一个非常聪明的 CSS hack,可以解决 IE 特定的错误。

不过,您必须先将 DOCTYPE 行换成 REAL DOCTYPE。

这里是链接中的代码,经过调整成为一个工作示例。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
/* all browsers make border red */
#IE { border : 2px solid red; }
/* all browsers see this, but only IE thinks #IEroot exists as an element and makes border blue */
#IEroot #IE { border-color : blue; }
</style>
</head>
<body>
<!--[if IE]>
<div id="IEroot">
<![endif]-->
<p id="IE">This browser is IE. (red in all, blue in IE)</p>
<p id="notIE">This browser is not IE.</p>
<!--[if IE]>
</div>
<![endif]-->
</body>
</html>

关于css - 使用#IEroot 进行针对 ie 的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/402337/

相关文章:

html - 一张背景图片分成多个div

javascript - 元素的 FormData 不起作用 - Internet Explorer 10

css - 买了一个@font-face,在 Firefox 和 IE 中不起作用

jQuery onchange 事件在 IE8 中触发两次

javascript - Div 行为不稳定。关于崩溃和崩溃

jquery - 如何判断我通过 JavaScript 包含的 CSS 文件是否已加载?

javascript - 根据 URL 动态更改 DIV 的 css - Angular

css - 浏览器测试时是否在本地保存css规则?

css - WebKit 的 Internet Explorer 兼容样式表?

html - css 按钮未显示在任何版本的 IE 中