CSS Hacks for Browsers_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:58:33
Original
1122 people have browsed it

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

我不再使用CSS Hacks了,相反的是,我将使用IE的条件判断将类应用到body标签。

 

但是,我想记录我之前碰到过的每一个浏览器特定的CSS 选择器和样式属性。我相信也没有其他方式提供样式表给独特的Safari.

 

利用这些CSS Hacks,你能够更好的针对IE、Chrome、Firefox、Opera和Safari,代码如下:

 

浏览器特定的CSS Hacks综合列表:

   1:  
Copy after login
   2: /***** Selector Hacks ******/
Copy after login
   3:  
Copy after login
   4: /* IE6 and below */
Copy after login
   5: * html #uno  { color: red }
Copy after login
   6:  
Copy after login
   7: /* IE7 */
Copy after login
   8: *:first-child+html #dos { color: red }
Copy after login
   9:  
Copy after login
  10: /* IE7, FF, Saf, Opera  */
Copy after login
  11: html>body #tres { color: red }
Copy after login
  12:  
Copy after login
  13: /* IE8, FF, Saf, Opera (Everything but IE 6,7) */
Copy after login
  14: html>/**/body #cuatro { color: red }
Copy after login
  15:  
Copy after login
  16: /* Opera 9.27 and below, safari 2 */
Copy after login
  17: html:first-child #cinco { color: red }
Copy after login
  18:  
Copy after login
  19: /* Safari 2-3 */
Copy after login
  20: html[xmlns*=""] body:last-child #seis { color: red }
Copy after login
  21:  
Copy after login
  22: /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
Copy after login
  23: body:nth-of-type(1) #siete { color: red }
Copy after login
  24:  
Copy after login
  25: /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
Copy after login
  26: body:first-of-type #ocho {  color: red }
Copy after login
  27:  
Copy after login
  28: /* saf3+, chrome1+ */
Copy after login
  29: @media screen and (-webkit-min-device-pixel-ratio:0) {
Copy after login
  30:  #diez  { color: red  }
Copy after login
  31: }
Copy after login
  32:  
Copy after login
  33: /* iPhone / mobile webkit */
Copy after login
  34: @media screen and (max-device-width: 480px) {
Copy after login
  35:  #veintiseis { color: red  }
Copy after login
  36: }
Copy after login
  37:  
Copy after login
  38:  
Copy after login
  39: /* Safari 2 - 3.1 */
Copy after login
  40: html[xmlns*=""]:root #trece  { color: red  }
Copy after login
  41:  
Copy after login
  42: /* Safari 2 - 3.1, Opera 9.25 */
Copy after login
  43: *|html[xmlns*=""] #catorce { color: red  }
Copy after login
  44:  
Copy after login
  45: /* Everything but IE6-8 */
Copy after login
  46: :root *> #quince { color: red  }
Copy after login
  47:  
Copy after login
  48: /* IE7 */
Copy after login
  49: *+html #dieciocho {  color: red }
Copy after login
  50:  
Copy after login
  51: /* IE 10+ */
Copy after login
  52: @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
Copy after login
  53:    #veintiun { color: red; }
Copy after login
  54: }
Copy after login
  55:  
Copy after login
  56: /* Firefox only. 1+ */
Copy after login
  57: #veinticuatro,  x:-moz-any-link  { color: red }
Copy after login
  58:  
Copy after login
  59: /* Firefox 3.0+ */
Copy after login
  60: #veinticinco,  x:-moz-any-link, x:default  { color: red  }
Copy after login
  61:  
Copy after login
  62: /* FF 3.5+ */
Copy after login
  63: body:not(:-moz-handler-blocked) #cuarenta { color: red; }
Copy after login
  64:  
Copy after login
  65:  
Copy after login
  66: /***** Attribute Hacks ******/
Copy after login
  67:  
Copy after login
  68: /* IE6 */
Copy after login
  69: #once { _color: blue }
Copy after login
  70:  
Copy after login
  71: /* IE6, IE7 */
Copy after login
  72: #doce { *color: blue; /* or #color: blue */ }
Copy after login
  73:  
Copy after login
  74: /* Everything but IE6 */
Copy after login
  75: #diecisiete { color/**/: blue }
Copy after login
  76:  
Copy after login
  77: /* IE6, IE7, IE8, but also IE9 in some cases :( */
Copy after login
  78: #diecinueve { color: blue\9; }
Copy after login
  79:  
Copy after login
  80: /* IE7, IE8 */
Copy after login
  81: #veinte { color/*\**/: blue\9; }
Copy after login
  82:  
Copy after login
  83: /* IE6, IE7 -- acts as an !important */
Copy after login
  84: #veintesiete { color: blue !ie; } /* string after ! can be anything */
Copy after login
  85:  
Copy after login
  86: /* IE8, IE9 */
Copy after login
  87: #anotherone  {color: blue\0/;} /* must go at the END of all rules */
Copy after login
  88:  
Copy after login
  89: /* IE9, IE10 */
Copy after login
  90: @media screen and (min-width:0\0) {
Copy after login
  91:     #veintidos { color: red}
Copy after login
  92: }
Copy after login

 

来源:http://www.ido321.com/509.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template