设置CSS只有IE浏览器? [英] Setting CSS for IE only?

查看:193
本文介绍了设置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.

这篇关于设置CSS只有IE浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆