gpt4 book ai didi

css hacks 和重写它们

转载 作者:太空宇宙 更新时间:2023-11-04 00:21:25 25 4
gpt4 key购买 nike

我已经停止为不同的浏览器使用 CSS hack,而是支持“条件注释将类添加到 html 标记”方法。

这让我想到了我的问题。我如何编写这个 ie8 hack 没有 hack

.grab-cursor{cursor:move\0/;}

我希望实现:

.ie8 .grab-cursor{--此处非黑客代码--;}

(我从来没有真正理解过 css hacks,所以我很高兴现在不必使用它们!)

最佳答案

.grab-cursor{cursor:move;}

你真的不需要任何 hack 或评论,它应该在所有浏览器上都能很好地工作(参见 http://www.quirksmode.org/css/cursor.html )。您要解决的问题到底是什么?

编辑

如果您使用条件注释 block ,则回答如何将某些样式应用于某些版本的 IE 而无需 hack 的一般问题

<!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 */

关于css hacks 和重写它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9020789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com