【发布时间】:2021-05-26 05:45:41
【问题描述】:
我有取决于设备 I.E 的媒体查询
@media only screen and (device-width: 375px) and (device-height: 812px) {
//iphone x
...some css
}
@media only screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) {
//iphone 6,7,8
... same css as iPhone x
}
@media only screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) {
//iphone 6/7/8 plus
... same css again
}
etc..
如您所见,由于某种原因我无法合并媒体查询,我多次重复代码,我尝试了:
@media only screen and (device-width: 375px) and (device-height: 812px) and (device-width: 375px) and (device-height: 667px) {
...some css
}
将 iPhone X 与 iPhone 6、7、8 查询结合使用,但不适用于 iPhone 6、7、8。如果我使用相同的 CSS 规则,是否可以合并所有这些规则?问候
【问题讨论】:
-
@media only screen and (device-width: 375px and device-height: 812px and device-width: 375px and device-height: 667px) { -
使用逗号将多个媒体查询组合成一条规则
标签: css