If you use media queries, use only the rules under the body element, which has a responsive class.
@media screen and (max-width: 320px) { body.responsive { color: blue; } }
If the user does not want to view the responsive layout, simply remove the โresponsiveโ class from the body element, invalidating all the rules. You can save cookie preferences or in any other way.
Demo: http://jsbin.com/obaquq/edit#javascript,html
Reducing the window to 500 pixels will cause the text to be white and the background blue. This is because the body has a โresponsiveโ class. Clicking on the first paragraph will switch this class and thus switch the effects of the media query itself.
Sampson
source share