仅在 IE 上应用样式 [英] Apply style ONLY on IE
问题描述
这是我的 CSS 块:
Here is my block of CSS:
.actual-form table {
padding: 5px 0 15px 15px;
margin: 0 0 30px 0;
display: block;
width: 100%;
background: #f9f9f9;
border-top: 1px solid #d0d0d0;
border-bottom: 1px solid #d0d0d0;
}
我只希望 IE 7、8 和 9 能够看到"width: 100%
I only want IE 7, 8, and 9 to "see" width: 100%
实现此目的最简单的方法是什么?
What is the simplest way to accomplish this?
推荐答案
2017 年更新
根据环境,条件注释已经正式弃用并在 IE10+ 中删除.
Depending on the environment, conditional comments have been officially deprecated and removed in IE10+.
原创
最简单的方法可能是使用 HTML 中的 Internet Explorer 条件注释:
The simplest way is probably to use an Internet Explorer conditional comment in your HTML:
<!--[if IE]>
<style>
.actual-form table {
width: 100%;
}
</style>
<![endif]-->
有许多黑客攻击(例如 underscore hack) 您可以使用它来只针对样式表中的 IE,但是如果您想针对所有平台上的所有 IE 版本,这会变得非常混乱.
There are numerous hacks (e.g. the underscore hack) you can use that will allow you to target only IE within your stylesheet, but it gets very messy if you want to target all versions of IE on all platforms.
这篇关于仅在 IE 上应用样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!