media query for min-height

2019-07-07 04:51发布

I want to write media query based on screen resolution. My screen resolution height is 768. I wrote media query for this as:

@media(min-height:768px) and (max-height:850px) {
   .video-contain{
     margin-top:110px;  
    }
}

My above media query is not working.margin-top is not set before. I wrote media query based for screen resolution but not browser height.

6条回答
爷的心禁止访问
2楼-- · 2019-07-07 04:55

Use:

@media screen and ( min-width: 850px ) and ( max-height: 768px )
{
   .video-contain{
     margin-top:110px;  
    }
}

NOTE: Always use max-width media queries to great effect.

查看更多
SAY GOODBYE
3楼-- · 2019-07-07 04:55

It seems like the issue is that your viewport is not the full resolution of your screen.

If you set the min-height to something lower, such as 720px, it ought to work.

 @media(min-height:720px) and (max-height:850px)
{
   .video-contain{
     margin-top:110px;
    }

 }
查看更多
ら.Afraid
4楼-- · 2019-07-07 05:07

You can define as like this.

@media screen and (max-width: 1600px) and (max-height: 900px){
    //code here
}

@media screen and (max-width: 1600px) and (max-height: 1200px){
        //code here
}

Or avoid mentioning width

@media screen and (max-height: 1200px){
            //code here
}
查看更多
做自己的国王
5楼-- · 2019-07-07 05:07

@media only screen and (max-width: 375px) and (max-height:667px) { }

查看更多
相关推荐>>
6楼-- · 2019-07-07 05:09

Please try this:

@media only screen and (min-width: 768px) and (max-width: 850px) {
}
查看更多
何必那么认真
7楼-- · 2019-07-07 05:13
//simple max-width query
@media screen and ( min-height: 600px ){
    background: blue;
    ....
}

This might help you.

查看更多
登录 后发表回答