如何在 ie6 上不显示 css 阴影?
我想知道是否可以忽略 ie6 上的 css 阴影而不使用条件语句来过滤 css。
这是我当前的 css:
/* Drop shadow */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000');
box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-o-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
也许 -ms-filter-ie6: none
或类似的东西 :P
I want to know if I can ignore my css drop shadow on ie6 without using conditional statements to filter the css.
here is my current css:
/* Drop shadow */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000');
box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-o-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.7);
Maybe -ms-filter-ie6: none
or something :P along those lines
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在
-ms-filter:
行下方添加以下行应该可以工作:* html
只能由 IE6 读取。但这是 CSS hack,这是非常糟糕的做法。您应该使用条件语句。Adding the following line below your
-ms-filter:
line should work:The
* html
is read only by IE6. But that is a CSS hack, which is very bad practice. You should use conditionals instead.使用仅 IE CSS 条件注释 禁用 IE6/Win 的专有过滤器:
'< a href="http://msdn.microsoft.com/en-us/library/ms532876%28v=vs.85%29.aspx" rel="nofollow">enabled' 过滤器属性是一个布尔值,需要 true 或 false 值来启用或禁用过滤器:
0 = false(过滤器已禁用)
1 = true(默认值。过滤器已启用)
Use an IE-Only CSS Conditional Comment that disables the proprietary filter for IE6/Win:
The 'enabled' filter attribute is a boolean that expects a true or false value to enable or disable the filter:
0 = false (Filter is disabled)
1 = true (Default value. Filter is enabled)
IE6 只知道
filter
,它无法识别-ms-filter
样式,因此删除filter
就可以了。缺点是这也会杀死 IE7。IE6 only knows about
filter
, it won't recognise the-ms-filter
style, so droppingfilter
would do the trick. The downside is that this would also kill it for IE7.您可以使用
/**/
hack。它应该被ie6忽略,但我没有ie6来测试它。
正如 Justin Satyr 所说,这是一个 hack,你应该使用条件注释。
You can use te
/**/
hack.It should be ignored by ie6, but I don't have ie6 to test it.
As Justin Satyr said it's a hack and you should use conditional comments.
我已经将条件放在
标记上:
然后在样式表中可以执行此操作(现在只需要一个样式表,并且 html 中没有内联样式)
如果您对于其他 IE 需要不同的代码,您可以添加更多条件。我有一个项目,其中 IE6、IE7、IE8 和 IE9 的至少一项行为都不同(但 FF、Chrome 和 Safari 很接近),因此有五个不同的
标签。
如果您使用 DreamWeaver,我听说您还需要在
周围添加相同的注释。
如果您需要针对其他浏览器的不同代码,则必须使用 jQuery 或类似的方法来添加类:例如
$('html').addClass('ff4');
尽管如果使用 js,情况可能会出乎意料未启用。I've been putting the conditionals on the
<html>
tag:And then in the style sheet one can do (you only need one style sheet now, and no inline styles in the html)
If you need different code for other IEs you can add more conditionals. I've had one project where IE6, IE7, IE8 and IE9 all behaved differently for at least one item (but FF, Chrome and Safari were close), so there was five different
<html>
tags.If you use DreamWeaver I've heard you'll need the same comments around the
</html>
as well.If you need different code for other browsers, you would have to use jQuery or similar to add classes: like
$('html').addClass('ff4');
though things might be unexpected if js is not enabled.