我已经停止对不同的浏览器使用CSS hacks,而是支持“将类添加到html标记的条件注释”方法。
这让我想到了我的问题。如何在没有黑客的情况下编写这个ie8 hack ?
.grab-cursor{cursor:move\0/;}
我正在寻求实施:
.ie8 .grab-cursor{
- 此处未被黑客入侵的代码 - ;}
(我从来没有真正理解css黑客,所以我很高兴现在不必使用它们!)
答案 0 :(得分:3)
.grab-cursor{cursor:move;}
这里你真的不需要任何黑客或评论,它应该适用于所有浏览器(参见http://www.quirksmode.org/css/cursor.html)。你想要解决的问题究竟是什么?
修改强>
如果您使用条件评论栏
,请回答如何将某些样式应用于某些版本的IE而不使用黑客的一般问题<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
你有各种各样的可能性。
如果您只想修复一般的Internet Explorer问题,可以使用
.oldie .grab-cursor {
/*IE-tailored css styles without the hack*/
}
然后你就定了。如果你想修复一些东西,比如IE7,你可以使用
.ie7 .grab-cursor {
/*IE-tailored css styles without the hack*/
}
但解决某些问题的最佳方法是使用modernizr(http://www.modernizr.com/),这样你就可以做像
这样的事情/* style I'm currently using in production */
.cssgradients #main nav{
background: linear-gradient(left, black, #e00, black);
}
.no-cssgradients nav{
background: url(../img/nav-bg.png) center center repeat-y; /*image background as fallback */
}
我还建议http://leaverou.github.com/prefixfree/,因为它允许你拥有
background: radial-gradient(center, ellipse cover, #000000 49%,#8f0222 49%,#6d0019 100%);
而不是
background: #000000; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover, #000000 49%, #8f0222 49%, #6d0019 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(49%,#000000), color-stop(49%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, #000000 49%,#8f0222 49%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, #000000 49%,#8f0222 49%,#6d0019 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, #000000 49%,#8f0222 49%,#6d0019 100%); /* IE10+ */
background: radial-gradient(center, ellipse cover, #000000 49%,#8f0222 49%,#6d0019 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#6d0019',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */