首页 > 代码库 > css hacks

css hacks

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

原文地址:http://css-tricks.com/snippets/css/browser-specific-hacks/

css hacks