代码之家  ›  专栏  ›  技术社区  ›  karthick

iPad css方向

  •  3
  • karthick  · 技术社区  · 15 年前

    @media only screen and (device-width:768px) and(orientation:portrait) {
      body { background: green; }
    }
    
    
    @media only screen and (device-width:768px) and(orientation:landscape) {
      body { background: red; }
    } 
    

    我不确定这是否有效。我试着在iphone模拟器上测试,将设备宽度改为320px,但没有成功。我需要更改这个css文件中的任何内容吗? 这就是我在主页面中调用css的方式

    <link rel="stylesheet" type="text/css" href="iPad.css" />"
    
    2 回复  |  直到 13 年前
        1
  •  4
  •   Owen Ryan Doherty    13 年前

    这就是我使用横向和纵向样式表来调用样式表的方法:

    <link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" href="css/landscape.css">
    <link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" href="css/portrait.css">
    

    我还找到了一个非常有用的链接:

    http://perishablepress.com/press/2010/10/20/target-iphone-and-ipad-with-css3-media-queries/

        2
  •  3
  •   karthick    13 年前

    我用这个css解决了这个问题。

       @media only screen and (device-width:768px) and(orientation:portrait) {
          body { background: green; }
        }
    
    
        @media only screen and (device-width:768px) and(orientation:landscape) {
          body { background: red; }
        }