0

Hi I would like to know how to disable a whole CSS3 stylesheet in either HTML or CSS. My css is almost all animations, so I would just like to know how to disable to whole thing

  • 1
    Stick the css in a media query, E.g. `@media only screen and (max-device-width: 480px) { ..css..}` – Alex K. Nov 02 '15 at 13:30
  • How would you determine if the user is on a mobile? What about tablets? If you're happy to pick an arbitrary size then you could just wrap the lot in a [media-query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) otherwise you're gonna have to do some dirty browser sniffing. – Moob Nov 02 '15 at 13:31
  • I had to switch max to min but it still worked. Thank you for helping @moob didn't see you. I only want it on mobile phones. I want tablets to see it. – Turtle Man Nov 02 '15 at 13:39

1 Answers1

0

If you do not mind using a JS library like Modernizr you can do the following :

if ( Modernizr.touch ) {
    // if mobile device disable stylesheets
    for ( i=0; i<document.styleSheets.length; i++) {
        void(document.styleSheets.item(i).disabled=true);
    }
}

I don't think you can be 100% sure whether it is mobile device or not

Raja Khoury
  • 3,015
  • 1
  • 20
  • 19