【必备】史上最全的浏览器 CSS & JS Hack 手册
【必备】史上最全的浏览器 CSS & JS Hack 手册
浏览器渲染页面的方式各不相同,甚至同一浏览器的不同版本(“杰出代表”是 IE)也有差异。因此,浏览器兼容成为前端开发人员的必备技能。如果有一份浏览器 Hack 手册,那查询起来就方便多了。这篇文章就向大家分享 Browserhacks 帮我们从网络上收集的各个浏览器特定的 CSS & JavaScript Hack,记得推荐和分享啊!
IE 选择器 Hack
1
2
3
|
/* IE 6 and below */ * html .selector {} .suckyie 6 .selector {} /* .suckyie6 can be any unused class */ |
1
2
|
/* IE 7 and below */ .selector, {} |
1
2
3
4
|
/* IE 7 */ *:first-child+html .selector {} .selector, x:-IE 7 {} *+html .selector {} |
/* Everything but IE 6 */ html > body .selector {} |
1
2
3
|
/* Everything but IE 6/7 */ html > /**/ body .selector {} head ~ /* */ body .selector {} |
1
2
3
4
5
|
/* Everything but IE 6/7/8 */ :root *> .selector {} body:last-child .selector {} body:nth-of-type( 1 ) .selector {} body:first-of-type .selector {} |
IE 属性/值 Hack
1
2
3
|
/* IE 6 */ .selector { _color : blue ; } .selector { - color : blue ; } |
1
2
3
|
/* IE 6/7 - acts as an !important */ .selector { color : blue !ie; } /* string after ! can be anything */ |
1
2
3
4
5
6
7
|
/* IE 6/7 - any combination of these characters: ! $ & * ( ) = % + @ , . / ` [ ] # ~ ? : < > | */ .selector { ! color : blue ; } .selector { $ color : blue ; } .selector { & color : blue ; } .selector { * color : blue ; } /* ... */ |
1
2
3
|
/* IE 8/9 */ .selector { color : blue \ 0 /; } /* must go at the END of all rules */ |
1
2
|
/* IE 9/10 */ .selector:nth-of-type( 1 n) { color : blue \ 9 ; } |
1
2
3
|
/* IE 6/7/8/9/10 */ .selector { color : blue \ 9 ; } .selector { color /*\**/ : blue \ 9 ; } |
1
2
|
/* Everything but IE 6 */ .selector { color /**/ : blue ; } |
IE Media Query Hack
1
2
|
/* IE 6/7 */ @media screen \ 9 {} |
1
2
|
/* IE 8 */ @media \ 0 screen {} |
1
2
|
/* IE 9/10, Firefox 3.5+, Opera */ @media screen and (min-resolution: + 72 dpi) {} |
1
2
|
/* IE 10+ */ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none ) {} |
1
2
|
/* IE 6/7/8 */ @media \ 0 screen\, screen \ 9 {} |
1
2
|
/* IE 8/9/10 & Opera */ @media screen \ 0 {} |
1
2
|
/* IE 9/10 */ @media screen and ( min-width : 0 \ 0 ) {} |
1
2
|
/* Everything but IE 6/7/8 */ @media screen and ( min-width : 400px ) {} |
IE JavaScript Hack
1
2
3
|
/* IE 6 */ (checkIE = document.createElement( "b" )).innerHTML = "<!--[if IE 6]><i></i><![endif]-->" ; var isIE = checkIE.getElementsByTagName( "i" ).length == 1; |
1
2
3
4
|
/* IE 7 */ (checkIE = document.createElement( "b" )).innerHTML = "<!--[if IE 7]><i></i><![endif]-->" ; var isIE = checkIE.getElementsByTagName( "i" ).length == 1; navigator.appVersion.indexOf( "MSIE 7." )!=-1 |
1
2
|
/* IE <= 8 */ var isIE = '\v' == 'v' ; |
1
2
3
|
/* IE 8 */ (checkIE = document.createElement( "b" )).innerHTML = "<!--[if IE 8]><i></i><![endif]-->" ; var isIE = checkIE.getElementsByTagName( "i" ).length == 1; |
1
2
3
|
/* IE 9 */ (checkIE = document.createElement( "b" )).innerHTML = "<!--[if IE 9]><i></i><![endif]-->" ; var isIE = checkIE.getElementsByTagName( "i" ).length == 1; |
1
2
|
/* IE 10 */ var isIE = eval( "/*@cc_on!@*/false" ) && document.documentMode === 10; |
1
2
|
/* IE 10 */ var isIE = document.body.style.msTouchAction != undefined; |
Firefox 浏览器
选择器 Hack
1
2
|
/* Firefox 1.5 */ body:empty .selector {} |
1
2
|
/* Firefox 2+ */ .selector, x:-moz-any-link {} |
1
2
|
/* Firefox 3+ */ .selector, x:-moz-any-link; x: default {} |
1
2
|
/* Firefox 3.5+ */ body:not(:-moz-handler-blocked) .selector {} |
媒体查询 Hack
1
2
|
/* Firefox 3.5+, IE 9/10, Opera */ @media screen and (min-resolution: + 72 dpi) {} |
1
2
|
/* Firefox 3.6+ */ @media screen and (-moz-images-in-menus: 0 ) {} |
1
2
|
/* Firefox 4+ */ @media screen and (min--moz-device-pixel-ratio: 0 ) {} |
JavaScript Hack
1
2
|
/* Firefox */ var isFF = !!navigator.userAgent.match(/firefox/i); |
1
2
|
/* Firefox 2 - 13 */ var isFF = Boolean(window.globalStorage); |
1
2
|
/* Firefox 2/3 */ var isFF = /a/[-1]== 'a' ; |
1
2
|
/* Firefox 3 */ var isFF = ( function x(){})[-5]== 'x' ; |
Chrome 浏览器
选择器 Hack
1
2
|
/* Chrome 24- and Safari 5- */ ::made-up-pseudo-element, .selector {} |
媒体查询 Hack
1
2
|
/* Chrome, Safari 3+ */ @media screen and (-webkit-min-device-pixel-ratio: 0 ) {} |
JavaScript Hack
1
2
|
/* Chrome */ var isChrome = Boolean(window.chrome); |
Safari 浏览器
选择器 Hack
1
2
3
|
/* Safari 2/3 */ html[xmlns*= "" ] body:last-child .selector {} html[xmlns*= "" ]:root .selector {} |
1
2
|
/* Safari 2/3.1, Opera 9.25 */ *|html[xmlns*= "" ] .selector {} |
1
2
|
/* Safari 5- and Chrome 24- */ ::made-up-pseudo-element, .selector {} |
媒体查询 Hack
1
2
|
/* Safari 3+, Chrome */ @media screen and (-webkit-min-device-pixel-ratio: 0 ) {} |
JavaScript Hack
1
2
|
/* Safari */ var isSafari = /a/.__proto__== '//' ; |
Opera 浏览器
选择器 Hack
1
2
|
/* Opera 9.25, Safari 2/3.1 */ *|html[xmlns*= "" ] .selector {} |
1
2
|
/* Opera 9.27 and below, Safari 2 */ html:first-child .selector {} |
1
2
|
/* Opera 9.5+ */ noindex:-o-prefocus, .selector {} |
媒体查询 Hack
1
2
|
/* Opera 7 */ @media all and ( min-width : 0px ){} |
1
2
|
/* Opera 12- */ @media all and (-webkit-min-device-pixel-ratio: 10000 ), not all and (-webkit-min-device-pixel-ratio: 0 ) {} |
1
2
|
/* Opera, Firefox 3.5+, IE 9/10 */ @media screen and (min-resolution: + 72 dpi) {} |
1
2
|
/* Opera, IE 8/9/10 */ @media screen {} |
JavaScript Hack
1
2
|
/* Opera 9.64- */ var isOpera = /^ function \(/.test([].sort); |
1
2
|
/* Opera 12- */ var isOpera = Boolean(window.opera); |
【必备】史上最全的浏览器 CSS & JS Hack 手册的更多相关文章
- 【必备】史上最全的浏览器 CSS & JS Hack 手册(转)
浏览器渲染页面的方式各不相同,甚至同一浏览器的不同版本(“杰出代表”是 IE)也有差异.因此,浏览器兼容成为前端开发人员的必备技能.如果有一份浏览器 Hack 手册,那查询起来就方便多了.这篇文章就向 ...
- 史上最全的浏览器 CSS & JS Hack 手册
浏览器渲染页面的方式各不相同,甚至同一浏览器的不同版本(“杰出代表”是 IE)也有差异.因此,浏览器兼容成为前端开发人员的必备技能.如果有一份浏览器 Hack 手册,那查询起来就方便多了.这篇文章就向 ...
- 【收藏】史上最全的浏览器 CSS & JS Hack 手册
浏览器渲染页面的方式各不相同,甚至同一浏览器的不同版本(“杰出代表”是 IE)也有差异.因此,浏览器兼容成为前端开发人员的必备技能.如果有一份浏览器 Hack 手册,那查询起来就方便多了.这篇文章就向 ...
- 史上最全Html与CSS布局技巧
单列布局水平居中水平居中的页面布局中最为常见的一种布局形式,多出现于标题,以及内容区域的组织形式,下面介绍四种实现水平居中的方法(注:下面各个实例中实现的是child元素的对齐操作,child元素的父 ...
- 史上最全Html和CSS布局技巧
单列布局水平居中 水平居中的页面布局中最为常见的一种布局形式,多出现于标题,以及内容区域的组织形式,下面介绍四种实现水平居中的方法(注:下面各个实例中实现的是child元素的对齐操作,child元 ...
- 新手必备 | 史上最全的PyTorch学习资源汇总
目录: PyTorch学习教程.手册 PyTorch视频教程 PyTorch项目资源 - NLP&PyTorch实战 - CV&PyTorch实战 PyTorch论 ...
- 史上最全的 UIWebview 的 JS 与 OC 交互
来源:伯乐在线 - 键盘风筝 链接:http://ios.jobbole.com/89330/ 点击 → 申请加入伯乐在线专栏作者 其实一直想给大家整理一下JS与OC的交互,但是没有合适的机会,今天借 ...
- 主流浏览器Css&js hack写法
参考: BROWSER HACKS 主流浏览器的Hack写法
- 史上最全的CSS hack方式一览
做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我们会极不情愿的使用这个不太友好的方式来达到大家要求的页面表现.我个人是不太推荐使用hack的,要知道 ...
随机推荐
- 代码实战之AdaBoost
尝试用sklearn进行adaboost实战 & SAMME.R算法流程,博客地址 初试AdaBoost SAMME.R算法流程 sklearn之AdaBoostClassifier类 完整实 ...
- spring 项目分开发和生产环境
1.pom 文件修改 <profile> <!-- 本地开发环境 --> <id>dev</id> <properties> <pro ...
- windows 2003 IIS FTP 530 home directory inaccessible
在 Windows Server 2003 及更新的版本中,IIS 中的 FTP 可以使用用户隔离了. 隔离有什么好处呢? 看起来更高级.比如 ftp1 用户打开的时候看到的路径是 /,但内容是自己文 ...
- call_user_func 和 call_user_func_array用法
说明 call_user_func 和 call_user_func_array 相同:都可以调用函数和类内部的函数,不同:不同的是传递的参数不同,前者是一个参数一个参数传递, 后者是传递array参 ...
- Mysql错误 ERROR 1064 (42000): You have an error in your SQL syntax
语法错误,可能有各种各样的问题. 我这个摔的太疼了. 字段名不能用空格..
- bzoj千题计划307:bzoj5248: [2018多省省队联测]一双木棋
https://www.lydsy.com/JudgeOnline/problem.php?id=5248 先手希望先手得分减后手得分最大,后手希望先手得分减后手得分最小 棋盘的局面一定是阶梯状,且从 ...
- C#窗口防止闪烁两种方法
public class PaintIncrease { public static void SetDoubleBuffered(object obj) { Type type = obj.GetT ...
- 2 Player and N Coin
class Solution { public void printChoices(int[] A, int[][] C) { System.out.println("硬币列表如下:&quo ...
- android BroadcastReceiver组件简单的使用
1.清单文件 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=& ...
- mysql 查询优化~join算法
一简介:参考了几位师兄,尤其是M哥大神的博客,让我恍然大悟,赶紧记录下二 原理: mysql的三种算法 1 Simple Nested-Loop Join 将驱动表/外部表的结果集作为循环基础数据,然 ...