Posted By

Terion on 01/20/12


Tagged

css browser hacks compatibility


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ljayz
danfolt


Css Browser Hack


 / Published in: CSS
 

generic css browser 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. /***** Attribute Hacks ******/
  56.  
  57. /* IE6 */
  58. #once { _color: blue }
  59.  
  60. /* IE6, IE7 */
  61. #doce { *color: blue; /* or #color: blue */ }
  62.  
  63. /* Everything but IE6 */
  64. #diecisiete { color/**/: blue }
  65.  
  66. /* IE6, IE7, IE8 */
  67. #diecinueve { color: blue\9; }
  68.  
  69. /* IE7, IE8 */
  70. #veinte { color/*\**/: blue\9; }
  71.  
  72. /* IE6, IE7 -- acts as an !important */
  73. #veintesiete { color: blue !ie; } /* string after ! can be anything */

Report this snippet  

You need to login to post a comment.