删除 IE 特定样式表中的 border-radius 样式
我的页面上包含两个 css 文件。
<link rel="stylesheet" href="/css/screen.css" />
<!--[if IE 8]>
<link rel="stylesheet" href="/css/ie8.css"/>
<![endif]-->
现在在 screen.css 中我有这样的样式
ul.treelayout{
list-style: none;
margin: 0px 0px 10px 0px;
background-color: #fff;
padding: 3px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #007b40;
}
我想删除 ie.css 中与半径相关的样式,这样 IE 中 ul.treelayout 的结果样式是
ul.treelayout{
list-style: none;
margin: 0px 0px 10px 0px;
background-color: #fff;
padding: 3px;
border: 1px solid #007b40;
}
似乎由于样式级联简单地编写没有 ie.css 中样式的类不起作用。有什么想法吗?
谢谢
问候 加布里埃尔
I have two css files included on my page.
<link rel="stylesheet" href="/css/screen.css" />
<!--[if IE 8]>
<link rel="stylesheet" href="/css/ie8.css"/>
<![endif]-->
Now in screen.css I have a style like this
ul.treelayout{
list-style: none;
margin: 0px 0px 10px 0px;
background-color: #fff;
padding: 3px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #007b40;
}
I would like to remove the radius related styles in the ie.css such that the result style of ul.treelayout in IE is
ul.treelayout{
list-style: none;
margin: 0px 0px 10px 0px;
background-color: #fff;
padding: 3px;
border: 1px solid #007b40;
}
It seems that due to the fact that the styles cascade simply writing the class without the styles in ie.css doesn't do the trick. Any ideas?
Thanks
Regards
Gabriel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我不是要解释为什么;) - 但你可以反过来做,只给 非 IE 浏览器 提供
border-radius
样式.. 事实上通过条件注释的组合,您可以为 IE9 和其他浏览器提供边框半径样式,我不知道您的意思是哪个脚本发生冲突,但也许您也可以将脚本提供给需要它的浏览器?这是一个示例(不使用 border-radius 但希望您能明白这个想法..)
HTML:
关于上述条件注释..
第一个是常规样式,
第二个是“传统”隐藏条件注释,只有 IE 才能看到
第三个是显示注释,所有浏览器都可以看到,但 IE 仍然读取
您将通用规则放在普通工作表中的参数,以及边框半径里面的规则在第三个样式注释中的一个表中,
您可以更改第三个注释的参数,它基本上是说 if NOT IE OR is gt IE7
有关参数的更多信息:关于条件评论
Ok mine is not to reason why ;) - but you can do this the other way around and only give the
border-radius
styles to NON-IE browsers.. in fact with a combination of Conditional comments you can give the border radius styles to IE9 and other browsers, I don't know which script you mean is clashing but maybe you can also just give the script to the browsers that need it?here's an example (not using border-radius but hopefully you may get the idea..)
HTML:
About the above conditional comments..
the first is a regular style
the second is a "traditional" hidden conditional comment which Only IE sees
the third is a revealed comment which all browsers see but IE still reads the arguments
you would put the common rules in a normal sheet, and the border radius rules inside a sheet in the third style comment
you can change the argument of the third comment it's basically saying if NOT IE OR is gt IE7
More Information on arguments: About Conditional Comments
哒哒。
ta da.
由于样式表级联的方式,您只需要在 ie8.css 中包含此内容:
这将使所有样式保持相同,但它会删除 IE 边框半径。如果您想要进一步更改 IE,您可以根据需要添加它们。
覆盖始终包含的样式表时,您只需添加要覆盖的样式或已在您自定义的浏览器中显示的样式。这使得 css 文件更小,这对您的用户来说更好。
Due to the way the stylesheet will cascade, you only need to have this in your ie8.css:
This will keep all of the styles the same, except it will remove the IE border radius. If you want further IE changes you can add them in as you like.
When overwriting a stylesheet that is always included, you only need to add styles you want to overwrite or have show up in the browser you're customising for. This makes the css file smaller, which is better for your users.