Android

Selector Hacks

WebKit

.selector:not(*:root) {}
  • Chrome *
  • Safari *
  • Opera ≥ 14
  • Android *

JavaScript Hacks

var isChromium = !!window.chrome;
  • Chrome *
  • Opera ≥ 14
  • Android 4.0.4

Media Query Hacks

@media screen and (min-width:0\0) {}
  • Internet Explorer ≥ 9
  • Safari 4
  • Android ≥ 2.3

Chrome

Selector Hacks

WebKit

.selector:not(*:root) {}
  • Chrome *
  • Safari *
  • Opera ≥ 14
  • Android *

Supports Hacks

@supports (-webkit-appearance:none) {}
  • Chrome ≥ 28
  • Opera ≥ 14

Property/Value Hacks

.selector { (;property: value;); }.selector { [;property: value;]; }
  • Chrome ≤ 28
  • Safari ≤ 7
  • Opera ≥ 14

JavaScript Hacks

var isChromium = !!window.chrome;
  • Chrome *
  • Opera ≥ 14
  • Android 4.0.4

Webkit

var isWebkit = 'WebkitAppearance' in document.documentElement.style;
  • Chrome *
  • Safari ≥ 3
  • Opera ≥ 14
var isChrome = !!window.chrome && !!window.chrome.webstore;
  • Chrome ≥ 14

Media Query Hacks

@media \\0 screen {}
  • Chrome 22-28
  • Safari ≥ 7
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
  • Chrome ≥ 29
  • Opera ≥ 16

Firefox

Selector Hacks

body:empty .selector {}
  • firefox 1.5/2
body:last-child .selector, x:-moz-any-link {}
  • firefox ≥ 2
body:last-child .selector, x:-moz-any-link, x:default {}
  • firefox ≥ 3
body:not(:-moz-handler-blocked) .selector {}
  • firefox ≥ 3.5
_::-moz-progress-bar, body:last-child .selector {}
  • firefox ≥ 6
_::-moz-range-track, body:last-child .selector {}
  • firefox ≥ 21
_:-moz-tree-row(hover), .selector {}
  • firefox *

Everything but Firefox and Internet Explorer ≤8

_::selection, .selector:not([attr*='']) {}
  • Internet Explorer ≤ 8
  • firefox *

Supports Hacks

@supports (-moz-appearance:meterbar) {}
  • firefox ≥ 16
@supports (-moz-appearance:meterbar) and (display:flex) {}
  • firefox ≥ 22
@supports (-moz-appearance:meterbar) and (cursor:zoom-in) {}
  • firefox ≥ 24
@supports (-moz-appearance:meterbar) and (background-attachment:local) {}
  • firefox ≥ 25
@supports (-moz-appearance:meterbar) and (image-orientation:90deg) {}
  • firefox ≥ 26
@supports (-moz-appearance:meterbar) and (all:initial) {}
  • firefox ≥ 27
@supports (-moz-appearance:meterbar) and (list-style-type:japanese-formal) {}
  • firefox ≥ 28
@supports (-moz-appearance:meterbar) and (background-blend-mode:difference,normal) {}
  • firefox ≥ 30

JavaScript Hacks

var isFF = !!window.sidebar;
  • firefox *
var isFF = 'MozAppearance' in document.documentElement.style;
  • firefox *
var isFF = !!navigator.userAgent.match(/firefox/i);
  • firefox *
var isFF = typeof InstallTrigger !== 'undefined';
  • firefox ≥ 1.5
var isFF = !!window.globalStorage;
  • firefox 2-13
var isFF = /a/[-1]=='a';
  • firefox 2-3
var isFF = (function x(){})[-6]=='x';
  • firefox 2
var isFF = (function x(){})[-5]=='x';
  • firefox 3

Media Query Hacks

@media \0 all {}
  • firefox ≤ 3
@media screen and (-moz-images-in-menus:0) {}
  • firefox ≥ 3.6
@media screen and (min--moz-device-pixel-ratio:0) {}
  • firefox ≥ 4
@media all and (min--moz-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}@media all and (-moz-images-in-menus:0) and (min-resolution: .001dpcm) {}
  • firefox ≥ 8
@media all and (min--moz-device-pixel-ratio:0) { @media (min-width: 0px) {} }@media all and (-moz-images-in-menus:0) { @media (min-width: 0px) {} }
  • firefox ≥ 11
@media all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm) {}
  • firefox ≥ 29

Miscellaneous

@-moz-document url-prefix() {}
  • firefox ≥ 3

Internet Explorer

Selector Hacks

.unused-class can be any unused class

* html .selector {}.unused-class.selector {}
  • Internet Explorer ≤ 6

Everything but Internet Explorer 6

html > body .selector {}
  • Internet Explorer 6
.selector, {}
  • Internet Explorer ≤ 7
*:first-child+html .selector {}.selector, x:-IE7 {}*+html .selector {}body*.selector {}
  • Internet Explorer 7
.selector\ {}
  • Internet Explorer ≤ 7

Everything but Internet Explorer ≤7

html > /**/ body .selector {}head ~ /**/ body .selector {}
  • Internet Explorer ≤ 7

Everything but Firefox and Internet Explorer ≤8

_::selection, .selector:not([attr*='']) {}
  • Internet Explorer ≤ 8
  • firefox *

Everything but Internet Explorer ≤8

:root .selector {}body:last-child .selector {}body:nth-of-type(1) .selector {}body:first-of-type .selector {}.selector:not([attr*='']) {}
  • Internet Explorer ≤ 8

Everything but Internet Explorer ≤9

html[lang='\en'] .selector {}
  • Internet Explorer ≤ 9
_:-ms-input-placeholder, :root .selector {}
  • Internet Explorer ≥ 10
_:-ms-fullscreen, :root .selector {}
  • Internet Explorer ≥ 11

Property/Value Hacks

.selector { _property: value; }.selector { -property: value; }
  • Internet Explorer 6
.selector { property: value\9; }.selector { property/*\**/: value\9; }
  • Internet Explorer 6-8

Any combination of these characters: ! $ & * ( ) = % + @ , . / ` [ ] # ~ ? : < > |

.selector { !property: value; }.selector { $property: value; }.selector { &property: value; }.selector { *property: value; }.selector { )property: value; }.selector { =property: value; }.selector { %property: value; }.selector { +property: value; }.selector { @property: value; }.selector { ,property: value; }.selector { .property: value; }.selector { /property: value; }.selector { `property: value; }.selector { ]property: value; }.selector { #property: value; }.selector { ~property: value; }.selector { ?property: value; }.selector { :property: value; }.selector { |property: value; }
  • Internet Explorer ≤ 7

Acts as an !important; string after ! can be anything

.selector { property: value !ie; }
  • Internet Explorer ≤ 7

JavaScript Hacks

Check for Internet Explorer version

var ieVersion = /*@cc_on (function() {switch(@_jscript_version) {case 1.0: return 3; case 3.0: return 4; case 5.0: return 5; case 5.1: return 5; case 5.5: return 5.5; case 5.6: return 6; case 5.7: return 7; case 5.8: return 8; case 9: return 9; case 10: return 10;}})() || @*/ 0;
  • Internet Explorer 3-10
var isIE = document.all && !window.XMLHttpRequest;
  • Internet Explorer ≤ 6
var isIE = document.all && document.compatMode;
  • Internet Explorer 6-10
var isIE = !!window.ActiveXObject;
  • Internet Explorer 6-10
var isIE = document.all && !document.querySelector;
  • Internet Explorer ≤ 7
var isIE = document.all && window.XMLHttpRequest && !document.querySelector;
  • Internet Explorer 7
var isIE = document.all && window.XMLHttpRequest;
  • Internet Explorer 7-10
var isIE = navigator.appVersion.indexOf("MSIE 7.") !== -1;
  • Internet Explorer 7
var isIE = document.all && document.querySelector;
  • Internet Explorer 8-10
var isIE = document.all && !document.addEventListener;
  • Internet Explorer ≤ 8
var isIE = document.all && document.querySelector && !document.addEventListener;
  • Internet Explorer 8
var isIE = '\v'=='v';
  • Internet Explorer ≤ 8
var isIE = !+'\v1';
  • Internet Explorer ≤ 8
var isIE = document.all && !window.atob;
  • Internet Explorer ≤ 9
var isIE = document.all && document.addEventListener && !window.atob;
  • Internet Explorer 9
var isIE = document.all && document.addEventListener;
  • Internet Explorer 9-10
var isIE = document.all && window.atob;
  • Internet Explorer 10
var isIE = /*@cc_on!@*/false;
  • Internet Explorer ≤ 10

Check for Internet Explorer version

var ieVersion = (function() { if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) { return parseFloat( RegExp.$1 ); } else { return false; } })();
  • Internet Explorer ≤ 10
var isIE = eval("/*@cc_on!@*/false") && document.documentMode === 10;
  • Internet Explorer 10
var isIE = document.body.style.msTouchAction !== undefined;
  • Internet Explorer ≥ 10
var isIE = window.navigator.msPointerEnabled;
  • Internet Explorer ≥ 10
var isIE = 'behavior' in document.documentElement.style && '-ms-user-select' in document.documentElement.style;
  • Internet Explorer 10
var isIE = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style;
  • Internet Explorer 11

Media Query Hacks

@media screen\9 {}
  • Internet Explorer ≤ 7
@media \0screen\,screen\9 {}
  • Internet Explorer ≤ 8
@media \0screen {}
  • Internet Explorer 8
@media screen and (min-width:0\0) {}
  • Internet Explorer ≥ 9
  • Safari 4
  • Android ≥ 2.3
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {}
  • Internet Explorer ≥ 10

Everything but Internet Explorer and Safari ≤6

@media screen { @media (min-width: 0px) {} }
  • Internet Explorer *
  • Safari ≤ 6

Conditional comments

<!--[if IE 6]> Internet Explorer 6 <![endif]--><!--[if IE 7]> Internet Explorer 7 <![endif]--><!--[if IE 8]> Internet Explorer 8 <![endif]--><!--[if IE 9]> Internet Explorer 9 <![endif]-->
  • Internet Explorer 6-9
<!--[if lte IE 6]> Internet Explorer 6 or less <![endif]--><!--[if lte IE 7]> Internet Explorer 7 or less <![endif]--><!--[if lte IE 8]> Internet Explorer 8 or less <![endif]--><!--[if lte IE 9]> Internet Explorer 9 or less <![endif]-->
  • Internet Explorer 6-9
<!--[if gte IE 6]> Internet Explorer 6 or greater <![endif]--><!--[if gte IE 7]> Internet Explorer 7 or greater <![endif]--><!--[if gte IE 8]> Internet Explorer 8 or greater <![endif]--><!--[if gte IE 9]> Internet Explorer 9 or greater <![endif]-->
  • Internet Explorer 6-9
<!--[if IE]> Internet Explorer 9- <![endif]-->
  • Internet Explorer ≤ 9

Everything but Internet Explorer ≤9

<!--[if !IE]><!--> Everything but Internet Explorer ≤9 <!--<![endif]-->
  • Internet Explorer ≤ 9

Opera

Selector Hacks

*|html[xmlns*=""] .selector {}
  • Safari 2/3.1
  • Opera 9.25
html:first-child .selector {}
  • Opera ≤ 9.27
  • Safari 2
_:-o-prefocus, body:last-child .selector {}
  • Opera ≥ 9.5
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
  • Opera ≤ 11

WebKit

.selector:not(*:root) {}
  • Chrome *
  • Safari *
  • Opera ≥ 14
  • Android *

Supports Hacks

@supports (-webkit-appearance:none) {}
  • Chrome ≥ 28
  • Opera ≥ 14

Property/Value Hacks

.selector { (;property: value;); }.selector { [;property: value;]; }
  • Chrome ≤ 28
  • Safari ≤ 7
  • Opera ≥ 14

JavaScript Hacks

var isOpera = /^function \(/.test([].sort);
  • Opera ≤ 9.64

Replace X by the version

var isOpera = window.opera && window.opera.version() == X;
  • Opera ≤ 12
var isOpera = !!window.opera;
  • Opera ≤ 12.16
var isChromium = !!window.chrome;
  • Chrome *
  • Opera ≥ 14
  • Android 4.0.4

Webkit

var isWebkit = 'WebkitAppearance' in document.documentElement.style;
  • Chrome *
  • Safari ≥ 3
  • Opera ≥ 14
var isOpera = !!window.opera || /opera|opr/i.test(navigator.userAgent);
  • Opera *

Media Query Hacks

@media (min-resolution: .001dpcm) { _:-o-prefocus, .selector {} }
  • Opera ≥ 12
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
  • Chrome ≥ 29
  • Opera ≥ 16

Opera Mini

JavaScript Hacks

var isOperaMini = Object.prototype.toString.call(window.operamini) === '[object OperaMini]';
  • Opera Mini *
var isOperaMini = (navigator.userAgent.indexOf('Opera Mini') > -1);
  • Opera Mini *

Safari

Selector Hacks

WebKit

.selector:not(*:root) {}
  • Chrome *
  • Safari *
  • Opera ≥ 14
  • Android *
html:first-child .selector {}
  • Opera ≤ 9.27
  • Safari 2
html[xmlns*=""] body:last-child .selector {}html[xmlns*=""]:root .selector {}
  • Safari 2-3
*|html[xmlns*=""] .selector {}
  • Safari 2/3.1
  • Opera 9.25
_::-moz-svg-foreign-content, :root .selector {}
  • Safari 5.1-6

Property/Value Hacks

.selector { (;property: value;); }.selector { [;property: value;]; }
  • Chrome ≤ 28
  • Safari ≤ 7
  • Opera ≥ 14

JavaScript Hacks

Webkit

var isWebkit = 'WebkitAppearance' in document.documentElement.style;
  • Chrome *
  • Safari ≥ 3
  • Opera ≥ 14
var isSafari = /a/.__proto__=='//';
  • Safari ≤ 5
var isSafari = /constructor/i.test(window.HTMLElement);
  • Safari *
var isSafari = !!navigator.userAgent.match(/safari/i) && !navigator.userAgent.match(/chrome/i) && typeof document.body.style.webkitFilter !== "undefined" && !window.chrome;
  • Safari 6

Media Query Hacks

@media screen and (min-width:0\0) {}
  • Internet Explorer ≥ 9
  • Safari 4
  • Android ≥ 2.3

Everything but Internet Explorer and Safari ≤6

@media screen { @media (min-width: 0px) {} }
  • Internet Explorer *
  • Safari ≤ 6
@media \\0 screen {}
  • Chrome 22-28
  • Safari ≥ 7

各种奇妙的hack的更多相关文章

  1. 转载:移动web开发规范

    本文来源:http://blog.csdn.net/joueu/article/details/44329825 以下是规范建议,均是日常在开发当中的的一些经验,仅供参考. 移动web开发规范 一.头 ...

  2. html5手机常见问题与工具分享

    mobileTech A useful tools or tips list for mobile web application developing 这个项目收集移动端开发所需要的一些资源与小技巧 ...

  3. mobileTech

    A useful tools or tips list for mobile web application developing 这个项目收集移动端开发所需要的一些资源与小技巧 工具类网站 HTML ...

  4. (任寒韬)WebApp群主 - MobileTech 资料

    web app : http://www.lightapp.cn/brand/index/4101 https://github.com/jtyjty99999/mobileTech/blob/mas ...

  5. mobilehack -转

    # mobileHack##工具类网站 [HTML5 与 CSS3 技术应用评估](http://html5please.com/ "html5与css3技术应用评估") [各种奇 ...

  6. frontend-tools

    收集整理好用的前端开发利器(Collect good front-end development tools ) 1.w3cplus前端工具 2.jsfiddle在线JS代码调试工具 3.w3cfun ...

  7. 移动Web解决方案的链接收藏

    信息类 html5 浏览器兼容性查询 - 浏览器内建对象文档 es5规范浏览器兼容性表格 es6规范浏览器兼容性表格 stackoverflow 最靠谱的问题解决方案 github 开源代码网站 全球 ...

  8. css常用hack

    原文地址:css常用hack 突然想起今天早上在CNZZ看到的统计数据,使用IE6.7的用户比例还真多,看到之后我的心都碎了.微软都放弃了为毛还有这么多人不死心? 所以说,IE下的兼容还是得做的. – ...

  9. CSS3_01之选择器、Hack

    1.兄弟选择器:①相邻兄弟选择器:元素的后一个兄弟元素,选择器1+选择器2:②通用兄弟选择器:元素后的所有兄弟元素,选择器1~选择器2: 2.属性选择器:attr表示属性名称,elem表示元素名:①[ ...

随机推荐

  1. OPPO A7X 刷机小结

    OPPO A7X 刷机小结: 概述:根据网上找到的教程(MTK模式刷机教程),没有成功.在QQ上询问一位提供刷机服务的大神,说是只有老版本才能刷. 操作步骤: 刷机工具: MediaTek SP Fl ...

  2. shellcode 初次使用笔记

    winXP SP3 环境 (xp环境默认没开启栈不可执行机制,比较方便破解,如果已开启了,请自行百度如何关闭) dig.exe 目标文件 x86dbg调试工具 python 环境 打开准备好的目标软件 ...

  3. B1041. 考试座位号(15)

    这题比较简单,没有调试,一次通过,虽然简单,不过也有借鉴意义. #include<bits/stdc++.h> using namespace std; const int N=1005; ...

  4. Mabatis中#{}和${}的区别

    动态 sql 是 mybatis 的主要特性之一,在 mapper 中定义的参数传到 xml 中之后,在查询之前 mybatis 会对其进行动态解析.mybatis 为我们提供了两种支持动态 sql ...

  5. 《Linux内核分析》第三周学习报告

    <Linux内核分析>第三周学习报告                                    ——构造一个简单的Linux系统MenuOS 姓名:王玮怡  学号:201351 ...

  6. 《Linux内核设计与实现》第五周读书笔记——第十一章

    <Linux内核设计与实现>第五周读书笔记——第十一章 20135301张忻 估算学习时间:共2.5小时 读书:2.0 代码:0 作业:0 博客:0.5 实际学习时间:共3.0小时 读书: ...

  7. # linux读书笔记(3章)

    linux读书笔记(3章) 标签(空格分隔): 20135328陈都 第三章 进程管理 3.1 进程 进程就是处于执行期的程序(目标码存放在某种存储介质上).但进程并不仅仅局限于一段可执行程序代码( ...

  8. Python Pandas read_csv报错

    为实现文本去重(将前面采集的数据进行两两对比删除重复),写了以下代码. #-*- coding: utf-8 -*-import pandas as pd inputfile = 'e:/data/H ...

  9. Arduino与Air800开发板使用UART通信:传输DHT22传感器数据

    硬件介绍 Arduino Leonardo在数字引脚0(RX)和1(TX)进行串口通信时是使用“Serial1”,USB的串口通信使用的是“Serial”.在数字引脚0(RX)和1(TX)与USB是相 ...

  10. 一日游 + 进度psp

    假设我们全班同学及教师去吉林省吉林市1日游,请为这次活动给出规格说明书. 目录 1   引言 1.1   编写目的 1.2   项目背景 1.3   参考资料 2   需求分析 2.1   交通方式 ...