我已经不再对不同的浏览器使用CSS攻击,而是支持“有条件的注释将类添加到html标记”的方法。
这就引出了我的问题。如果没有黑客,我怎么写这个ie8黑客?
.grab-cursor{cursor:move\0/;}
我希望实现:
.ie8 .grab-cursor{--这里没有黑代码-- ;}
(我从来没有真正理解css黑客,所以我很高兴现在不用使用它们!)
发布于 2012-01-26 15:50:37
.grab-cursor{cursor:move;}您真的不需要在这里进行任何黑客攻击或评论,它应该在所有浏览器上都能很好地工作(参见http://www.quirksmode.org/css/cursor.html)。你到底想解决什么问题?
编辑
如果使用条件注释块,可以回答关于如何将某些样式应用于某些版本的IE而不使用hacks的一般问题。
<!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]-->你有各种各样的可能性。
如果您只想修复一般的问题,可以使用
.oldie .grab-cursor {
/*IE-tailored css styles without the hack*/
}你已经准备好了。如果您只想修复某些东西,比方说IE7,您可以使用
.ie7 .grab-cursor {
/*IE-tailored css styles without the hack*/
}但是解决某些问题的最好方法是使用现代化( 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 */https://stackoverflow.com/questions/9020789
复制相似问题