浏览器的CSS Hacks
LZ注:此文原作者是:Paul Irish(Google的前端开发工程师),本文是原文的部分译文.

我不再使用CSS Hacks了,相反的是,我将使用IE的条件判断将类应用到body标签。
但是,我想记录我之前碰到过的每一个浏览器特定的CSS 选择器和样式属性。我相信也没有其他方式提供样式表给独特的Safari.
利用这些CSS Hacks,你能够更好的针对IE、Chrome、Firefox、Opera和Safari,代码如下:
浏览器特定的CSS Hacks综合列表:
1:
2: /***** Selector Hacks ******/
3:
4: /* IE6 and below */
5: * html #uno { color: red }
6:
7: /* IE7 */
8: *:first-child+html #dos { color: red }
9:
10: /* IE7, FF, Saf, Opera */
11: html>body #tres { color: red }
12:
13: /* IE8, FF, Saf, Opera (Everything but IE 6,7) */
14: html>/**/body #cuatro { color: red }
15:
16: /* Opera 9.27 and below, safari 2 */
17: html:first-child #cinco { color: red }
18:
19: /* Safari 2-3 */
20: html[xmlns*=""] body:last-child #seis { color: red }
21:
22: /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
23: body:nth-of-type(1) #siete { color: red }
24:
25: /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
26: body:first-of-type #ocho { color: red }
27:
28: /* saf3+, chrome1+ */
29: @media screen and (-webkit-min-device-pixel-ratio:0) {
30: #diez { color: red }
31: }
32:
33: /* iPhone / mobile webkit */
34: @media screen and (max-device-width: 480px) {
35: #veintiseis { color: red }
36: }
37:
38:
39: /* Safari 2 - 3.1 */
40: html[xmlns*=""]:root #trece { color: red }
41:
42: /* Safari 2 - 3.1, Opera 9.25 */
43: *|html[xmlns*=""] #catorce { color: red }
44:
45: /* Everything but IE6-8 */
46: :root *> #quince { color: red }
47:
48: /* IE7 */
49: *+html #dieciocho { color: red }
50:
51: /* IE 10+ */
52: @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
53: #veintiun { color: red; }
54: }
55:
56: /* Firefox only. 1+ */
57: #veinticuatro, x:-moz-any-link { color: red }
58:
59: /* Firefox 3.0+ */
60: #veinticinco, x:-moz-any-link, x:default { color: red }
61:
62: /* FF 3.5+ */
63: body:not(:-moz-handler-blocked) #cuarenta { color: red; }
64:
65:
66: /***** Attribute Hacks ******/
67:
68: /* IE6 */
69: #once { _color: blue }
70:
71: /* IE6, IE7 */
72: #doce { *color: blue; /* or #color: blue */ }
73:
74: /* Everything but IE6 */
75: #diecisiete { color/**/: blue }
76:
77: /* IE6, IE7, IE8, but also IE9 in some cases :( */
78: #diecinueve { color: blue\9; }
79:
80: /* IE7, IE8 */
81: #veinte { color/*\**/: blue\9; }
82:
83: /* IE6, IE7 -- acts as an !important */
84: #veintesiete { color: blue !ie; } /* string after ! can be anything */
85:
86: /* IE8, IE9 */
87: #anotherone {color: blue\0/;} /* must go at the END of all rules */
88:
89: /* IE9, IE10 */
90: @media screen and (min-width:0\0) {
91: #veintidos { color: red}
92: }
来源:http://www.ido321.com/509.html
浏览器的CSS Hacks的更多相关文章
- 转:【总结】浏览器CSS Hacks汇总,浏览器兼容方式CSS Hacks
[总结]浏览器CSS Hacks汇总 浏览器兼容可以说是前端开发所要面对的第一个挑战,目前我的电脑上已经安装了6种浏览器(基于IE内核的不算,如Maxthon等). CSS hacks利用浏览器的 ...
- CSS Hacks 总结
CSS hack由于不同的浏览器,对CSS的解析认识不一样,因此会导致生成的页面效果不一样,我们就需要针对不同的浏览器去写不同的CSS,让他能在不同的浏览器中也能得到我们想要的页面效果. CSS ha ...
- 针对IE浏览器的CSS样式(兼容性)
1. IE hacks: "_" 是IE6 专有的hack; "\9" 对IE6-IE10都有效: "\0"对IE8-IE10都有效: & ...
- IE浏览器和CSS盒模型【转】
总结:css盒模型在不同浏览器之间(例如:ie和其他浏览器 如火狐)的差异只存在于ie6之前的版本中,如ie5.在ie6下, Internet Explorer 在标准模式下渲染时使用了 CSS 规范 ...
- 针对不同浏览器,CSS如何写
我们在开发DIV+CSS页面时候常常会遇到开发出的网页的一些地方在各大浏览器比如微软IE6.微软IE7.微软IE8.火狐浏览器.谷歌浏览器有一些不同,如宽度.高度等地方有相差误.IE6比较老的版本浏览 ...
- 兼容主流浏览器的CSS透明代码
透明往往能产生不错的网页视觉效果下面是兼容主流浏览器的CSS透明代码.transparent_class { filter:alpha(opacity=50); -moz-opacity:0.5; ...
- css hack 大全 各个浏览器的css
各个浏览器的css hack区别属性: IE6: _zoom:1; IE6/7: *zoom:1; IE6/7/8/9 :\9 各个浏览器的css hack区别规则 IE6: *html{} IE7: ...
- Javascript检测浏览器对CSS属性的支持 /* supports */
//检测浏览器对CSS属性的支持 supports = (function() { var div = document.createElement('div'), vendors = 'Khtml ...
- (转)兼容主流浏览器的CSS透明代码
透明往往能产生不错的网页视觉效果下面是兼容主流浏览器的CSS透明代码.transparent_class { filter:alpha(opacity=50); -moz-opacity:0.5; - ...
随机推荐
- 【贪心】bzoj 3709:[PA2014]Bohater
3709: [PA2014]Bohater Time Limit: 5 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 653 Solved: ...
- BZOJ 1697: [Usaco2007 Feb]Cow Sorting牛排序
Description 农夫JOHN准备把他的 N(1 <= N <= 10,000)头牛排队以便于行动.因为脾气大的牛有可能会捣乱,JOHN想把牛按脾气的大小排序.每一头牛的脾气都是一个 ...
- AndroidManifest.xml文件综合详解(转)
一,重要性AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根目 ...
- uva 10534
一开始WA了 参考了一下 求正反两个方向的最长上升子序列 并分别记录在两个数组中 最后求最大值 #include <iostream> #include <cstdio&g ...
- oracle-number(5,2)
insert into emp values(70000.123); 只能存储 整数的前3位, 小数点后面的2位
- 谈 DevOps 自动化时,也应该考虑到 SOX 等法案
[编者按]作者 Aaron Volkmann 是 CERT Division 高级研究员,在本文中,他对 DevOps 自动化违反 SOX 法案进行了阐述.同时,也简单的提出了如何通过 CI 来避免这 ...
- iOS开发的小技巧(断点打印)
iOS开发中我们会碰到这样的需求:打印沙盒目录,打印对象信息,对象信息可以通过断点查看,有时候对象属性繁多时看起来又比较麻烦. 今天学到一个比较实用的方法: 在运行时打一个断点,当程序停在这个断点后, ...
- node.js模块之Buffer模块
http://nodejs.org/api/buffer.html Pure JavaScript is Unicode friendly but not nice to binary data. W ...
- uva 11817 - Tunnelling the Earth
题意:从地球上的一个点到另一个点,求两点的球面距离和直线距离之差.假定地球是正球体,半径为6371009米. #include<iostream> #include<cmath> ...
- 给枚举加上Description,必要时,可以直接获取枚举类型代表的中文
http://www.cnblogs.com/lyl6796910/p/3958768.html