×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: CSS
Posted by: Rodrigo (Digão) Ferreira
Added: Jun 17, 2013 8:13 PM
Views: 24
Tags: css hacks
source: http://www.paulirish.com/2009/browser-specific-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.  
  38. /* Safari 2 - 3.1 */
  39. html[xmlns*=""]:root #trece  { color: red  }
  40.  
  41. /* Safari 2 - 3.1, Opera 9.25 */
  42. *|html[xmlns*=""] #catorce { color: red  }
  43.  
  44. /* Everything but IE6-8 */
  45. :root *> #quince { color: red  }
  46.  
  47. /* IE7 */
  48. *+html #dieciocho {  color: red }
  49.  
  50. /* IE 10+ */
  51. @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  52.    #veintiun { color: red; }
  53. }
  54.  
  55. /* Firefox only. 1+ */
  56. #veinticuatro,  x:-moz-any-link  { color: red }
  57.  
  58. /* Firefox 3.0+ */
  59. #veinticinco,  x:-moz-any-link, x:default  { color: red  }
  60.  
  61. /* FF 3.5+ */
  62. body:not(:-moz-handler-blocked) #cuarenta { color: red; }
  63.  
  64.  
  65. /***** Attribute Hacks ******/
  66.  
  67. /* IE6 */
  68. #once { _color: blue }
  69.  
  70. /* IE6, IE7 */
  71. #doce { *color: blue; /* or #color: blue */ }
  72.  
  73. /* Everything but IE6 */
  74. #diecisiete { color/**/: blue }
  75.  
  76. /* IE6, IE7, IE8, but also IE9 in some cases :( */
  77. #diecinueve { color: blue\9; }
  78.  
  79. /* IE7, IE8 */
  80. #veinte { color/*\**/: blue\9; }
  81.  
  82. /* IE6, IE7 -- acts as an !important */
  83. #veintesiete { color: blue !ie; } /* string after ! can be anything */
  84.  
  85. /* IE8, IE9 */
  86. #anotherone  {color: blue\0/;} /* must go at the END of all rules */
  87.  
  88. /* IE9, IE10 */
  89. @media screen and (min-width:0\0) {
  90.     #veintidos { color: red}
  91. }