css - 适用于 iPad Pro 12.9 第三代的 CSS 媒体查询
问题描述
我正在尝试检测上述设备并相应地调整网页内容的大小。
以下查询适用于除 12.9 英寸第三代以外的所有 iPad Pro 设备。有谁知道宽度/高度的正确参数?
/* iPad pro */
@media only screen
and (min-device-width: 1024px)
and (max-device-width: 1366px)
and (-webkit-min-device-pixel-ratio: 2)
{
}
我现在已经按照建议尝试了下面的代码。它仍然不适用于 iPad Pro 12.9 第 3 代。附上 iPad 模拟器的截图。登录部分应该填满屏幕的宽度
/* Landscape*/
@media only screen and (min-device-width: 1366px) and (max-device-height: 1024px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape)
{
div.information
{
width:1290px;
padding-left:20px;
padding-right:20px;
padding-top:5px;
padding-bottom:5px;
border-radius: 20px;
margin-bottom:10px;
}
}
/* Portrait*/
@media only screen and (min-device-width: 1024px) and (max-device-height: 1366px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait)
{
div.information
{
width:950px;
padding-left:20px;
padding-right:20px;
padding-top:5px;
padding-bottom:5px;
border-radius: 20px;
margin-bottom:10px;
}
}
解决方案
以下查询应该适合您。我在声明中添加了一个方向问题,以指定您拿着 iPad 的方式。此外,您需要将最大值替换为高度值,而不是使用 2 个宽度值(这将根据您是以横向还是纵向方式握持设备而变化。
/* Landscape*/
@media only screen and (min-device-width: 1366px) and (max-device-height: 1024px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape) {}
/* Portrait*/
@media only screen and (min-device-width: 1024px) and (max-device-height: 1366px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {}
推荐阅读
- mysql - 如何验证 cachePrepStmts 在 Spring Boot 中是否正常工作
- visual-studio - 从命令行集成服务导入项目向导
- loops - Google App Script:在 Google 表格中动态添加新行
- php - 我可以指定 Laravel 响应返回的标头的顺序吗?
- blazor - Blazor Virtualize 组件在水平滚动时中断
- reactjs - 网格元素在移动版本上超出容器
- django - 如何在 django rest 框架中获取模型中的记录数?
- firebase - Firebase / Firestore 模拟器无法通过本地网络访问
- sql - @ 字符前的字符串通配符
- javascript - Angular 从模块 JSON 生成纯 HTML