解析错误@media only屏幕和(方向:横向)

时间:2016-11-26 21:26:05

标签: css

我有这个媒体查询css:不知何故它只是不会通过验证,但如果我取出方向查询,它将成功验证。我根本找不到任何错误。所有花括号都是平衡的,可能是错的?

/ *媒体查询--- MOB * /

@media screen and (min-width:200px) and (max-width: 640px) {
/* ....CSS classes.... */

@media only screen and (orientation: landscape) {    
    .loginImgDiv {
    margin-left: 70%; 
    width:100%; 
    height:auto; 
    }
  } /* End of @media only screen and (orientation: landscape)*/
  @media only screen and (orientation: portrait) {
    .loginImgDiv {
    margin-left: 45%; 
    width:100%; 
    height:auto; 
    }
  } /* End of  @media only screen and (orientation: portrait)*/
} /*End of media query---MOB */

1 个答案:

答案 0 :(得分:0)

我认为你必须将两种方向分开,你不能混合它们

点击此链接orientation reference

将其更改为以下

@media screen and (min-width:200px) and (max-width: 640px) and (orientation:landscape){
/* ....CSS classes.... */


    .loginImgDiv {
    margin-left: 70%; 
    width:100%; 
    height:auto; 
    }
}
@media screen and (min-width:200px) and (max-width: 640px) and (orientation:potrait){
  .loginImgDiv{
    margin-left: 45%; 
    width:100%; 
    height:auto; 
    }
  } /* End of  @media only screen and (orientation: portrait)*/
 /*End of media query---MOB */

希望有所帮助