CSS媒体查询是否可以检测人像/风景平板电脑模式? [英] CSS media queries is it possible to detect portrait / landscape tablet mode?
本文介绍了CSS媒体查询是否可以检测人像/风景平板电脑模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设在JS中很容易....像
if(window.innerHeight> window.innerWidth ){
portrait = true;
} else {
portrait = false;
}
我可以使用...但我想知道是否可能只使用css和@media风格
是可能的像
@media only screen and(width> height){
// ...
}
解决方案是的:
@media screen and(orientation:portrait){...}
@media屏幕和(orientation:landscape){...}
媒体查询的CSS定义位于 http://www.w3.org/TR/css3-mediaqueries/#orientation
given that in JS is pretty easy ....something like
if(window.innerHeight > window.innerWidth){ portrait = true; }else{ portrait = false; }
and i can use that...but i'm wondering if it is possible to do it using just css and @media styles
is it possible something like
@media only screen and (width > height) { //... }
解决方案Yes you do it:
@media screen and (orientation:portrait) { … } @media screen and (orientation:landscape) { … }
The CSS definition of a media query is at http://www.w3.org/TR/css3-mediaqueries/#orientation
这篇关于CSS媒体查询是否可以检测人像/风景平板电脑模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文