【问题标题】:showing media on google dev tool but not on iphone在谷歌开发工具上显示媒体,但不在 iPhone 上
【发布时间】:2023-04-10 03:13:01
【问题描述】:

我本来打算演示屏幕分辨率和响应式网页,但在我设法在谷歌开发工具 iPhone 7 屏幕模拟器上展示了一个示例之后,但尝试在实际手机上浏览该页面并且它是空白的。

我添加了meta name:viewpoint 并确保所有内容都指向正确的文件。总而言之,它应该像在模拟器上显示的那样工作。

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title> iPhone 6 %amp; 7 will show</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
        <style>

/* shows the same display on both landscape and portrait */

        /* iPhone 7 in portrait & landscape */
    /* @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) {
        body{
            background-image: url('imgs/P-375px.jpg') 
        }

    } */

/* comment out to only show in portrait */

    /* iPhone 7 in landscape */
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : landscape) {
        body{
            background-image: url('imgs/L-667px.jpg') 
        }
        .box{
            background:pink;
            width:20%;
            height: 20%;
            padding:5%;
            border: red 2px solid;
            color:green;
        }
    }

/* comment out to only show in landscape */

    /* iPhone 7 in portrait */
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : portrait) {
        body{
            background-image: url('imgs/P-375px.jpg') 
        }
        .box{
            background:yellow;
            width:20%;
            height: 20%;
            padding:5%;
            border: blue 2px solid;
            color:orange;
        }
    }
        </style>
    </head>
    <body>
        <div class="box"></div>

    </body>
    </html>

【问题讨论】:

    标签: html css responsive-design media-queries google-developer-tools


    【解决方案1】:

    只需将min-device-width 更改为min-width 并将max-device-width 更改为max-width - 您在媒体查询中使用的像素值实际上是“css 像素”,而不是“设备像素”(由于视网膜显示器)

    【讨论】:

    • 谢谢,但将 min-device-width 更改为 min-width 并将 max-device-width 更改为 max-width 无效
    • 对不起,Johannes 假设了一个正确的答案,但它并不正确。我已将 min-device-width 编辑为 min-width 并将 max-device-width 编辑为 max-width ,但屏幕上仍然没有出现任何内容。请问其他人可以参与吗?
    猜你喜欢
    • 2013-01-16
    • 2011-10-08
    • 1970-01-01
    • 1970-01-01
    • 2019-10-17
    • 1970-01-01
    • 2013-08-18
    • 2017-11-08
    • 1970-01-01
    相关资源
    最近更新 更多