设置CSS只有IE浏览器?

设置CSS只有IE浏览器?

问题描述:

我有隐藏,直到它的父元素悬停在一个简单的 DIV 与2px的粗边框和绝对定位,多数民众赞成。由于IE的盒模型,位置说 DIV 有点关在IE浏览器,而不是任何其他浏览器。我不想增加对IE一个完全独立的样式表,我只是想,如果浏览者使用IE修改类本身。

I have a simple div with a 2px thick border and absolute positioning thats hidden until its parent element is hovered over. Due to IEs box model, the position of said div is somewhat off in IE, but not any other browser. I don't want to add an entirely seperate style sheet for IE, I just want to modify the class itself if the browsing person is using IE.

那么,如何修改添加特定类IE只?

So how does one modify or add a specific class for IE only?

您需要使用一种叫做条件注释。在IE中只有这些工作(其他的浏览器会看到他们的意见),所以他们只针对IE浏览器的好方法。

You need to use something called conditional comments. These only work in IE (other browsers will see them as comments) so they are a great way to target IE only.

示例 - 如果你想在IE6做什么用的以下内容:

Example - if you want something to be done in IE6 use the following:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]--

要了解更多信息,请访问官方对于有条件的评论 MSDN来源。

To find out more, visit the official MSDN source regarding conditional comments.