@media query not working in mobile. Works fine in Chrome
@Andy is right, double check your device-widths
, or you could always just use min-width
so you don't have to know every device width.
Regardless make sure you have a viewport
tag, like <meta name="viewport" content="width=device-width,initial-scale=1.0">
.
@media query works fine in Chrome, but not working on mobile
It is most likely your phone is wider than 400px
therefore doesn't enter the media query condition.
You can achieve what you want without using media queries, just using max-width
with width
like this:
.home-wrapper {
position: relative;
max-width:1366px;
width: 100%; /*or another value you want here like 90% or 90vw */
/* just for demo */
height: 200px;
background: lightblue
}
<div class="home-wrapper"></div>
media query working on chrome but not on mobile
You should add this meta tag in <head></head>
. More information from MDN
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Media query works on mobile Firefox but doesn't work on mobile Chrome
Add this meta tag into the header of your HTML file:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
This should solve your problem. Otherwise the browser might not resize because it will not accept that the screen size is meeting your media query criteria.
Why are my CSS3 media queries not working on mobile devices?
All three of these were helpful tips, but it looks like I needed to add a meta tag:
<meta content="width=device-width, initial-scale=1" name="viewport" />
Now it seems to work in both Android (2.2) and iPhone all right...
Responsive media query not working in Google Chrome
add this line in <head>
<meta name="viewport" content="width=device-width,initial-scale=1">
Related Topics
Outlining and Partially Filling an Svg Shape
Preventing "Double" Borders in CSS
Bootstrap 3 - Desktop View on a Mobile Device
Calc of Max, or Max of Calc in CSS
What Does an "&" Before a Pseudo Element in CSS Mean
Svg in Img Element Proportions Not Respected in IE9
Using CSS, Can You Apply a Gradient Mask to Fade to the Background Over Text
How to Style the Resize Grabber of Textarea
Changing Font Colour in Textboxes in Ie Which Are Disabled
Make Child Visible Outside an Overflow:Hidden Parent
How to Transition CSS Display + Opacity Properties
How to Change the Height of an Image in CSS :Before/:After Pseudo-Elements
Common CSS Media Queries Break Points
How to Get the Scroll Bar with CSS Overflow on iOS
How to Create Div to Fill All Space Between Header and Footer Div