博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
浏览器的CSS Hacks
阅读量:4287 次
发布时间:2019-05-27

本文共 2577 字,大约阅读时间需要 8 分钟。

LZ注:此文原作者是:(Google的前端开发工程师),本文是原文的部分译文。

我不再使用CSS Hacks了,相反的是,

 

但是,我想记录我之前碰到过的每一个浏览器特定的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://bgvgi.baihongyu.com/

你可能感兴趣的文章
iOS之Header Search Paths和User Header Search Paths和library searchpath、pch(prefix header)、pods文件路径
查看>>
iOS之开发编码规范
查看>>
iOS中状态栏网络加载指示器
查看>>
PHP之MAC上环境配置
查看>>
iOS之WKWebView修改网页页面的值
查看>>
PHP之数据库设计
查看>>
iOS之NSLog控制台打印不完全的解决方法
查看>>
iOS之github、oschina、bitboucket使用(二)
查看>>
iOS 之AFN封装(四)常用
查看>>
iOS 企业版账号的使用
查看>>
iOS 多线程控制线程并发数、GCD之dispatch_group、GCD信号量、验证码按钮倒计时
查看>>
iOS 之NSRange实现小数向上取整
查看>>
PHP 之XML编程,注释总结
查看>>
iOS之SHA1算法
查看>>
iOS之hHTTPS的使用
查看>>
iOS之返回按钮
查看>>
PHP 之smarty、webservice、RSS订阅
查看>>
iOS之http协议
查看>>
iOS之静态库
查看>>
iOS 之适配字体的几中方法
查看>>