ios - 如何为 iPad 保持相同样式的 `portrait` 到 `landscape`

标签 ios css ipad

一些原因,我需要保持与portrait相同的样式到landscape。如何使用 css3 媒体查询实现这一点?

因为触摸板禁用了一些功能。

我试过了,但它仍然显示桌面 View

@media screen and (max-device-width:1024px){}

最佳答案

您可能想查看 this也。下面是ios相关的。

   


/* iPads (portrait and landscape) ----------- */

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
  /* Styles */
}


/* iPads (landscape) ----------- */

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
  /* Styles */
}


/* iPads (portrait) ----------- */

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
  /* Styles */
}


/**********
iPad 3
**********/

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 2) {
  /* Styles */
}

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 2) {
  /* Styles */
}



/* iPhone 4 ----------- */

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 2) {
  /* Styles */
}

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 2) {
  /* Styles */
}


/* iPhone 5 ----------- */

@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}

@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}


/* iPhone 6 ----------- */

@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}

@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}


/* iPhone 6+ ----------- */

@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}

@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2) {
  /* Styles */
}

关于ios - 如何为 iPad 保持相同样式的 `portrait` 到 `landscape`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47325543/

相关文章:

ios - UINavigationController 推送因无法识别的选择器 barStyle 而崩溃

ios - testflight会改变App ID吗?

iphone - 防止 iPhone 对 HTML 表单元素进行圆 Angular 处理

css - 元素上的动画无法在 Chrome、Opera 和 IE 中运行

iphone - 在 UITableView 之上覆盖 View

ios - 有没有一种无需手动更改原点/大小/中心即可在 iOS 中重新定位 View 的简单方法?

ios - swift-stdlib-tool 失败,退出代码为 1

javascript - 动态扩展文本区域时,将 View 保持在页面底部

iOS 7 Popover Controller 在 xcode 6 下崩溃

objective-c - 多个可滚动 subview / TableView