CSS: max-width for @media query not working

Have you tried adding the viewport in? <meta name=”viewport” content=”width=device-width, initial-scale=1″> Working JSFiddle Viewport is used when rendering responsive pages and is therefore mostly used when dealing with mobile websites, but when dealing with media queries it helps tell the CSS what the actual device-width is.

calc() not working within media queries

ANSWER EDITED AGAIN 21.03.2022: In the current version of the spec, using calc (or var) in media queries is NOT supported by the spec (as TylerH pointed out below). Properties sometimes accept complex values, e.g., calculations that involve several other values. Media features* only accept single values: one keyword, one number, etc. * Media features … Read more

CSS media queries for screen sizes

Put it all in one document and use this: /* Smartphones (portrait and landscape) ———– */ @media only screen and (min-device-width : 320px) and (max-device-width : 480px) { /* Styles */ } /* Smartphones (landscape) ———– */ @media only screen and (min-width : 321px) { /* Styles */ } /* Smartphones (portrait) ———– */ @media … Read more

Nesting @media rules in CSS

For those simply looking for an answer to “Which browsers support nesting of @media rules?”, the short answer is that all modern browsers, including Firefox, Safari, Chrome (and its derivatives), and Microsoft Edge, now support nesting of @media at-rules as described in CSS Conditional 3. The code in the question with the nested @media at-rules … Read more

Is it possible to emulate orientation in a browser?

In Chrome Dev Tools: If you go to Settings>Overrides>Device metrics If you swap the dimensions for the screen resolution the orientation will change and the orientationchange-event will be triggered. The orientation is depending on the relationship between ‘width’ and ‘height’. If ‘height’ has a higher value than ‘width’, the browser will be in orientation: ‘portrait’ … Read more

Achieving min-width with viewport meta tag

So you want to change the viewport tag’s width dynamicaly . Here you go : <meta id=”myViewport” name=”viewport” content=”width = 380″> <script> window.onload = function () { var mvp = document.getElementById(‘myViewport’); mvp.setAttribute(‘content’,’width=580′); } </script> See:http://www.quirksmode.org/mobile/tableViewport.html