浏览器的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; - ...
随机推荐
- VS2008的默认打开重置为VS2008
- 在Oracle SQL Developer中创建新连接
步骤: 1.如下图 2.点击“测试”,如果左下角的状态出现“成功”,说明OK
- html css 如何将表头固定(转)
html css 如何将表头固定 position属性取值为fixed时,则元素的位置将不受滚动条的影响,而是直接依据窗口定位,这就是将表头固定的最直接方法,网上其他途径感觉都是在走弯路.但是与此同时 ...
- [转载]汇编eax寄存器和AX,AH,AL之间的关系
00000000 00000000 00000000 00000000|===============EAX===============|---32个0,4个字节,2个字,1个双字 ...
- 团体程序设计天梯赛-练习集L1-011. A-B
L1-011. A-B 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你计算A-B.不过麻烦的是,A和B都是字符串 — ...
- HDU1465+递推
经典的信封装信问题 f[ n ] = ( n-1 ) * ( f[ n-1 ]+f[ n-2 ] ) #include<stdio.h> #include<string.h> ...
- hibernate annotation注解 columnDefinition用法
column注解中的columnDefinition属性用于覆盖数据库DDL中的语句:(MySql) @Column(columnDefinition = "int(11) DEFAULT ...
- Servlet课程0424(三) 通过继承HttpServlet来开发Servlet
//这是第三种开发servlet的方法,通过继承httpservlet package com.tsinghua; import javax.servlet.http.*; import java.i ...
- 网上图书商城项目学习笔记-035工具类之JdbcUtils及TxQueryRunner及C3P0配置
事务就是保证多个操作在同一个connection,TxQueryRunner通过JdbcUtils获取连接,而JdbcUtils通过ThreadLocal<Connection>确保了不同 ...
- 去除右键菜单opendlg
环境:windows8.1专业版 未知文件类型,右键会多出一个opendlg的选项!下面是移除的方法: 将下面的内容复制到记事本,并另存为XXX .reg,导入注册表即可! Windows Reg ...