【问题标题】:Media query to target both smartphone portrait and landscape at the same time同时针对智能手机纵向和横向的媒体查询
【发布时间】:2017-11-05 14:44:17
【问题描述】:

我希望将一些样式应用于智能手机,无论是纵向还是横向。

是否有针对这两种情况的良好媒体查询?实际上我必须用两个媒体查询重复css:

.selector {

// smartphone portrait
@media (min-width: 320px}) and (max-width: 512px}) {
    // stuff
}

// smartphone landscape
@media only screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape) {
    // same stuff
}

}

【问题讨论】:

    标签: html css media-queries stylesheet


    【解决方案1】:

    我相信,如果您创建一个媒体查询,其中 min-width 是纵向手机屏幕宽度,max-width 是横向手机屏幕宽度,无论方向如何,它都应该涵盖所有内容。

    【讨论】:

    • 在这种情况下,我认为它也将针对具有调整大小的浏览器窗口的 dekstop。不过我会试试的,谢谢
    猜你喜欢
    • 2013-06-30
    • 1970-01-01
    • 2013-04-03
    • 2012-12-04
    • 1970-01-01
    • 2013-03-08
    • 2014-12-12
    • 2012-12-22
    • 2015-08-17
    相关资源
    最近更新 更多