方向:横屏/竖屏
结合CSS媒体查询,可以创建适应不同设备的方向(横屏landscape、竖屏portrait等)的布局。
语法:
orientation:portrait | landscape
portrait:指定输出设备中的页面可见区域高度大于或等于宽度
landscape: 除portrait值情况外,都是landscape
实例:
<style>
/*竖屏*/
@media only screen and (orientation:portrait) {
body *{ display:none !important;}
body:after{ content:"现在是竖屏"; width:100%; height:100%; text-align:center; display:flex; align-items:center; justify-content:center;}
}
/*横屏*/
@media only screen and (orientation:landscape) {
body *{ display:none !important;}
body:after{ content:"现在是横屏"; width:100%; height:100%; text-align:center; display:flex; align-items:center; justify-content:center;}
}
</style>