【问题标题】:iphone 5 landscape media queryiphone 5横向媒体查询
【发布时间】:2012-09-17 19:11:43
【问题描述】:

我看到很多关于 iphone 5 纵向的媒体查询,但没有针对横向模式的媒体查询,有吗?我问这个问题是因为我正在为客户工作的这个网站对纵向和横向模式有单独的媒体查询,我将这个 iPhone 5 CSS media query 添加到我建议的 iphone 4 纵向媒体查询中,但想知道如何处理景观部分

@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5),only screen (min-device-width:640px) and (max-device-width:1136px) and (-webkit-min-device-pixel-ratio:2) {
    body {
        background:#2d2928 url(images/bg960.jpg) no-repeat center top;
        background-size:480px 163px;
        font-size:96%;
        font-weight:300;
        padding:0 1%;
    }
    .logo a {
        display:block;
        margin:0 auto;
        width:260px;
        height:77px;
        background:url(images/logox2.png) no-repeat center center;
        _background:none;
        _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/logox2.png',sizingMethod='crop');
        background-size:260px 77px;
    }
    #container {
        width:99%;
        margin:0 auto;
    }
    .frontimagewrapper {
        width:80%;
    }
    h1 {
        font-size:124%;
    }
    h2,h3,h4,h5, {
        font-family:"Trebuchet MS",Arial,Helvetica,sans-serif;
        letter-spacing:0.2em;
        font-size:100%;
    }
    .gallery h2 {
        font-size:96%;
    }
    .block h3 {
        font-size:96%;
    }
    .article h3 {
        font-size:100%;
    }
    .article h2 {
        font-size:106.6%;
    }
    p {
        font-size:0.9em;
    }
    .date {
        font-size:0.8em;
    }
    .copyright {
        font-size: 0.9em;
    }
}
/*/mediaquery*/
@media only screen and (min-device-width:320px) and (max-device-width:480px) and (orientation:landscape) and (-webkit-min-device-pixel-ratio:2) {
    body {
        font-size:96%;
    }
    .frontimagewrapper {
        width:55%;
    }
    .blogleft img {
        max-width:60%;
        height:auto;
    }
    h1 {
        font-size:150%;
    }
    h2,h3,h4,h5, {
        font-family:"Trebuchet MS",Arial,Helvetica,sans-serif;
        letter-spacing:0.2em;
        font-size:100%;
    }
    .article h2 {
        font-size:118%;
    }
    .date {
        front-size:50%;
    }
    p {
        font-size:0.9em;
        line-height:1.825em;
    }
    .date {
        font-size:0.8em;
    }
    .copyright {
        font-size: 0.9em;
    }
}
/*/mediaquery*/

【问题讨论】:

    标签: iphone css


    【解决方案1】:

    iPhone 5 纵向和/或横向媒体查询

    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 568px) { 
        /* CSS here */
    }
    

    仅限横向 iPhone 5 的媒体查询

    @media only screen 
    and (min-device-width : 320px)
    and (max-device-width : 568px) 
    and (orientation : landscape) {
        /* CSS here */
    }
    

    【讨论】:

    • 我发现自己要达到 767 像素(比 iPad 高一个像素)才能赶上任何真正大的 Android 手机。
    【解决方案2】:

    不过,您可以根据“orientation”和“-webkit-device-pixel-ratio”为 iPhone 5 和 iPhone SE 指定媒体查询。

    /* Only iPhone 5 and iPhone SE(portrait mode) */
    @media only screen and (min-device-width: 320px) and (max-device-width: 568px)
    and (-webkit-device-pixel-ratio: 2) and (orientation:portrait)
    {
        body {
            color:blue;
        }
    }
    
    /* Only iPhone 5 and iPhone SE(landscape mode) */
    @media only screen and (min-device-width: 320px) and (max-device-width: 568px)
    and (-webkit-device-pixel-ratio: 2) and (orientation:landscape)
    {
        body {
            color:red;
        }
    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    	<title>Document</title>
    </head>
    <body>
    	Hello based on the device orientation my color will change
    </body>
    </html>

    【讨论】:

      猜你喜欢
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      • 2012-11-30
      • 2011-11-09
      • 2014-07-19
      • 1970-01-01
      • 2011-09-25
      相关资源
      最近更新 更多