有没有人能够成功使用 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/