简体   繁体   English

媒体查询在iPhone上不起作用

[英]Media Query doesn't work on iPhones

I have a problem with my RWD for iPhones. 我的iPhone RWD有问题。 It seems that every iPhone ignores my media query tag. 似乎每个iPhone都会忽略我的媒体查询标签。 Everything works fine on Chrome, Android and Windows Phone, but on iPhones all is in mess. 在Chrome,Android和Windows Phone上一切正常,但在iPhone上却一团糟。 How it's possible? 怎么可能?

I have this tag in my head section: 我的头部有这个标签:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 

Also i tried with 我也尝试过

@media only screen
@media min-device-width

And nothing. 没事了。 this is my full code: 这是我的完整代码:

@media screen and (min-width: 220px) and (max-width: 480px)
{

    html
    {
        height: 100%;
    }

    #header .saturn
    {
        width: 100%;

        margin-top: 35px;

        display: block;
        text-align: center;

        animation: rwdScaleSaturn 2s linear infinite;
        -webkit-animation: rwdScaleSaturn 2s linear infinite;
        transform: scale(0.8);
        -webkit-transform: scale(0.8);
    }

    #header .header-nav
    {
        margin: 0;

        display: block;
        text-align: center;
        float: none;
    }

    #header .header-nav ul
    {
        width: 100%;
        text-align: center;
    }

    #about .cloud.x1
    {
        display: none;
    }

    #about .cloud.x2
    {
        transform: scale(0.8);
        -webkit-transform: scale(0.8);
    }

    #about .cloud.x3
    {
        display: none;
    }

    #about .cloud.x4
    {
        display: none;
    }

    #about .cloud.x5
    {
        display: none;
    }

    #about .cloud.x7
    {
        right: 35%;
        top: 10%;

        animation: rwdAnimation 2s linear infinite;
        -webkit-animation: rwdAnimation 2s linear infinite;
    }

    #about .rocket
    {
        transform: scale(0.8);
        -webkit-transform: scale(0.8);

        margin-bottom: 15px;
        left: 80px;
        bottom: 50px;
    }

    #about .about-description
    {
        margin: 0;
        font-size: 12px;

    }

    #about .plane
    {
        display: none;
    }

    #about .ship
    {
        bottom: 60px;
        margin-left: 15px;
    }

    #portfolio
    {
        min-height: 400px;
    }

    #portfolio .title
    {
        padding-top: 15px;
        margin-bottom: 20px;
    }

    #contact .contact-description
    {
        font-size: 14px;
        margin-bottom: 25px;
    }

    #contact .mail
    {
        margin-bottom: 10px;
    }

    #contact .shark
    {
        transform: scale(0.8);
    }

}
<meta name="viewport" content="width=device-width, initial-scale=1.0">

@media only screen and (min-width: 220px) and (max-width: 480px){
    body{
        background:red;
    }
}

So, I figured it out. 所以,我想通了。 I created separate style file just for specific iPhones and linked it to the html. 我为特定的iPhone创建了单独的样式文件,并将其链接到html。 Everything works fine. 一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM