css - 离子 - 在某些设备上不遵守图像比例
问题描述
我使用 Ionic 框架制作了一个应用程序,但在某些设备上出现了问题。这是我的主页:
在某些设备(iPhone 5S、iPhone 5C、Samsung S5)上,页面显示如下:
这个页面是用离子网格制作的。这是我的 css 的一部分:
ion-grid{
height: 100%;
ion-row.homeM{
height: 20%;
img{
height: 80%;
}
p{
margin-top: 0px;
}
}
ion-row.homeML{
height: 25%;
img{
height: 75%;
}
p{
margin-top: 0px;
}
}
}
ion-row.homeM 用于纵向显示,ion-row.homeML 用于横向显示。
欢迎帮助:)!
谢谢
解决方案
要创建响应式设计,请尝试使用“vh for height”和“vw for width”或“em”而不是“px 或 %” , 试试这个:
ion-grid{
height:98vh;
ion-row.homeM{
height: 40vh;
img{
height: 100vh;
/*you can add max-height to prevent img to be stretched*/
max-height:100px;//for example
width:30vw;
}
p{
margin-top: 0px;
}
}
}
我希望这对您有所帮助,您可以从这里了解更多关于我所说的内容: ViewPort Unit
推荐阅读
- ios - firebase 没有在 tableview 中实时填充
- python - 从 anaconda 将 Python 嵌入到 C++ 中,出现错误
- python - django中的对象比较
- javascript - 重置日期输入类型,输入显示在禁用的文本区域上并附加在之后
- flutter - Flutter 图片库保护程序 - 如何访问路径
- scikit-learn - Sklearn GridSearchCV 可用内核列表
- python - 在 Pandas 中将 12 小时制转换为 24 小时制时间格式
- javascript - JavaScript 整数作为字符串返回
- c# - 加载资源失败:服务器响应状态为 500 () | Oracle & ASP.NET Core MVC 3.1
- java - 我尝试更改 javac.sublime-build-package,但通知访问被拒绝