简体   繁体   English

CSS媒体查询无法在特定屏幕上加载

[英]Css media query not loads with specific screen

I have to apply height for two different screen 1080px and 1000px. 我必须为两个不同的屏幕1080px和1000px应用高度。

I have added following media query: 我添加了以下媒体查询:

@media only screen and (max-height:1080px){
    #wrapper {
        width: 1884px;
        height: 1080px;
        float: left;
    }
    .filter-selection ul li
    {
        height:109px;
    }
}


@media only screen and (max-height:1000px){
    #wrapper {
        width: 1884px;
        height: 1000px;
        float: left;
    }

    .filter-selection ul li
    {
        height:106px;
    }
}

When i switched to 1080px the issues remain's same, it call's the media query for 1000px. 当我切换到1080px时,问题仍然存在,它称为1000px的媒体查询。

http://ddslauncher.com/inventory-new/ http://ddslauncher.com/inventory-new/

Thanks in advance. 提前致谢。

The media queries in your example are the other way round from your question. 您的示例中的媒体查询与您的问题相反。 They are: 他们是:

@media only screen and (max-height:1000px){

    #wrapper {
        width: 1884px;
        height: 1000px;
        float: left;
    }

    .filter-selection ul li
    {
        height:106px;;
    }
}


@media only screen and (max-height:1080px){
    #wrapper {
        width: 1884px;
        height: 1080px;
        float: left;
    }

    .filter-selection ul li
    {
        height:109px;;
    }
}

(the issue here is that when the screen is below 100px in height both queries match and the second one is applied ass CSS 'cascades' down.) (这里的问题是,当屏幕的高度低于100px时,两个查询都匹配,第二个查询向下应用CSS CSS“层叠”。)

instead of: 代替:

@media only screen and (max-height:1080px){

    #wrapper {
        width: 1884px;
        height: 1080px;
        float: left;
    }

    .filter-selection ul li
    {
        height:109px;
    }
}


@media only screen and (max-height:1000px){
    #wrapper {
        width: 1884px;
        height: 1000px;
        float: left;
    }

    .filter-selection ul li
    {
        height:106px;
    }
}

Using this second example should fix your issue. 使用第二个示例应该可以解决您的问题。

EDIT Apologies for the formatting issues, something is interfering with my SO edits. EDIT对于格式问题,很抱歉,某些内容干扰了我的SO编辑。

You can use the percentage width instead of fixed. 您可以使用百分比宽度代替固定宽度。 something like the following. 类似以下内容。 Also it would be great if you can run the media query based on Viewport width not height. 如果您可以根据视口宽度而不是高度运行媒体查询,那也很好。

@media only screen and (max-height:1080px){
#wrapper {
width: 100%;
height: 1080px;
float: left;
} 
}

I saw yours stylesheet. 我看到了你的样式表。 in css u have "min-height". 在CSS中,您具有“最小高度”。 I suggest to change into max-height, and used "!important" adnotation. 我建议更改为最大高度,并使用“!important”注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM