Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Media Queries not working on iPhone

Tags:

css

iphone

media

I am having trouble with my css media queries. They work great on the computer but don't work on my iPhone. Here is what i have:

@media only screen and (max-width: 400px) {
    .logInCenter{
        width:90%;
        left:0;
        top:0;
        margin-left:0px !important;
    }
}

@media only screen and (min-width: 401px) and (max-width: 768px) {

    .fluid-half
    {
        display:block;
        padding:20px 0px;
        width:100%;
        float:none;
    }

}

@media only screen and (min-width: 769px) and (max-width: 991px) {

}

@media only screen and (min-width: 992px) and (max-width: 1199px) {

}

@media only screen and (min-width: 1200px) {

}

The problem is that my iPhone only detects the styles when I put them in the third media query. The issue is that at 100% width, it looks just like any other desktop site. Really far away. I hope that makes sense! thanks!

like image 540
sethcarlton Avatar asked Dec 02 '22 21:12

sethcarlton


2 Answers

Have you made sure that the following code is in your HTMl head? Tells the devise to look at viewport sizes.

<meta name="viewport" content="width=device-width">
like image 74
Andy Smith Avatar answered Dec 22 '22 07:12

Andy Smith


Since you are using css media queries, you should not use meta tag in your html file. You can set the same in css using:

@viewport {
   width: device-width;
   zoom:1;
}
like image 41
samtamtam Avatar answered Dec 22 '22 07:12

samtamtam