Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: max-width for @media query not working

(It works on other browsers but not chrome)

I want to apply a style only when the browser size is less than 1400px

with max-width not working

@media only screen and (max-width:1400px)  { .heading-left {     left: -0.5%;   } } 

with min-width its working

@media only screen and (min-width:480px)  { .heading-left {     left: -0.5%;    } } 

But also alters when browser width is above 1400px (I know thats how it works but max-width is not working)

Fiddle for this

https://jsfiddle.net/j4Laddtk/

like image 979
Divya Barsode Avatar asked Jun 08 '15 10:06

Divya Barsode


People also ask

Why is @media not working?

Media process errors on Android can be triggered by a long list of factors. For example, maybe you're running low on RAM and storage space. Clear the cache, check for updates, remove the SD card and check if the error is gone. As a last resort, reset your device to factory settings.

Why my media query is not working in CSS?

CSS declared inline This may be the reason why your media queries aren't working. That is to say, you may have declared CSS within your HTML document. So if this is the case, simply go through the HTML document and remove the CSS declared inline.

How do I set media query between min and max?

If you want to include both min and max width for responsiveness in the browser, then you can use the following: @media (min-width: 768px) and (max-width: 992px){...} @media (min-width: 480px) and (max-width: 767px) {...}

What is @media min width?

Max-width and min-width can be used together to target a specific range of screen sizes. @media only screen and (max-width: 600px) and (min-width: 400px) {...} The query above will trigger only for screens that are 600-400px wide. This can be used to target specific devices with known widths.


1 Answers

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.

like image 172
Stewartside Avatar answered Oct 20 '22 06:10

Stewartside