删除 IE 特定样式表中的 border-radius 样式

发布于 2024-11-06 05:22:43 字数 803 浏览 1 评论 0原文

我的页面上包含两个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走过海棠暮 2024-11-13 05:22:43

好吧,我不是要解释为什么;) - 但你可以反过来做,只给 非 IE 浏览器 提供 border-radius 样式.. 事实上通过条件注释的组合,您可以为 IE9 和其他浏览器提供边框半径样式,我不知道您的意思是哪个脚本发生冲突,但也许您也可以将脚本提供给需要它的浏览器?

这是一个示例(不使用 border-radius 但希望您能明白这个想法..)

<style type="text/css" media="screen">
div {
padding: 40px;
color: #fff;
}
</style>

<!--[if IE]>
<style type="text/css" media="screen">
div  {background: #00f}
</style>
<![endif]-->

<!--[if (!IE)|(gt IE 7)]><!-->
<style type="text/css" media="screen">
div  {background: #f00}
</style>
<!--<![endif]-->

HTML:

<div>
   <p>background is red in non-IE browsers,and IE gt 7  - but background is blue in other IE's</p>
</div>

关于上述条件注释..

第一个是常规样式,

第二个是“传统”隐藏条件注释,只有 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..)

<style type="text/css" media="screen">
div {
padding: 40px;
color: #fff;
}
</style>

<!--[if IE]>
<style type="text/css" media="screen">
div  {background: #00f}
</style>
<![endif]-->

<!--[if (!IE)|(gt IE 7)]><!-->
<style type="text/css" media="screen">
div  {background: #f00}
</style>
<!--<![endif]-->

HTML:

<div>
   <p>background is red in non-IE browsers,and IE gt 7  - but background is blue in other IE's</p>
</div>

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

素罗衫 2024-11-13 05:22:43
ul.treelayout{
    list-style: none;
    margin: 0px 0px 10px 0px;   
    background-color: #fff;
    padding: 3px;
    border-radius: 0;
    -moz-border-radius: 0;
    -webkit-border-radius: 0;
    border: 1px solid #007b40;
}

哒哒。

ul.treelayout{
    list-style: none;
    margin: 0px 0px 10px 0px;   
    background-color: #fff;
    padding: 3px;
    border-radius: 0;
    -moz-border-radius: 0;
    -webkit-border-radius: 0;
    border: 1px solid #007b40;
}

ta da.

-黛色若梦 2024-11-13 05:22:43

由于样式表级联的方式,您只需要在 ie8.css 中包含此内容:

ul.treelayout {border-radius: 0;}

这将使所有样式保持相同,但它会删除 IE 边框半径。如果您想要进一步更改 IE,您可以根据需要添加它们。

覆盖始终包含的样式表时,您只需添加要覆盖的样式或已在您自定义的浏览器中显示的样式。这使得 css 文件更小,这对您的用户来说更好。

Due to the way the stylesheet will cascade, you only need to have this in your ie8.css:

ul.treelayout {border-radius: 0;}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文