html - iPad css 方向

标签 html css ipad orientation

我想通过使用 ipad 的 css 来测试方向。这是我使用的 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; }
} 

我不确定这是否有效。我尝试通过将设备宽度更改为 320px 在 iphone 模拟器中进行测试。但它没有用。我需要更改此 css 文件中的任何内容吗? 这就是我在主页中调用 css 的方式

<link rel="stylesheet" type="text/css" href="iPad.css" />"

最佳答案

这是我用来调用横向和纵向样式表的样式表:

<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/

关于html - iPad css 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3211720/

相关文章:

javascript - 将 css 文件链接到 node.js 服务器

javascript - 如何根据条件删除元素?

javascript - Facebook 登录无法在 iPad 上使用

javascript - 在 jquery 创建的新元素上使用 javascript

html - 如何在div的底部制作一个三 Angular 形

html - 在 HTML 中换行文本后的空白

iphone - iPhone可以设置视频报警吗?

php - 使用 php exec 和 javascript 执行 bash 脚本

javascript - 如何逐页滚动(逐格)?

ios - 核心数据,第一次运行时不会在 uitableview 中显示数据,第二次运行正常