【问题标题】:How to set @media (min-width) and (max-width) for both chrome and firefox如何为 chrome 和 firefox 设置 @media (min-width) 和 (max-width)
【发布时间】:2018-06-16 01:01:09
【问题描述】:

我想为平板设备设置一些 CSS 规则,为此我尝试将这些规则设置为 769px 和 991px 之间的屏幕。当我这样做时:

@media (min-width: 769px) and (max-width: 991px) {
    .img-circle {
        width: 50%;
    }
}

它适用于 chrome,但 firefox 不适用,当我尝试添加括号时:

@media ((min-width: 769px) and (max-width: 991px)) {
    .img-circle {
        width: 50%;
    }
}

它适用于 forefox,但不适用于 chrome ! 如果你有一个想法:) 我想不通

问候

【问题讨论】:

  • 试试 => @media all and (min-width: 769px) and (max-width: 991px) {

标签: html css google-chrome firefox media-queries


【解决方案1】:

尝试将您的代码更改为

    @media only screen /* adding only query */
    and (min-width: 769px) 
    and (max-width: 991px) {
        .img-circle {
            width: 50%;
        }
    }

并尝试在这个 repo 中与我们分叉 CSS3 Media Queries Template

有关更多信息,请参阅Responsive Web Design - Media Queries

【讨论】:

    【解决方案2】:

    使用所有浏览器

    .mm {
        background: cyan;
        width: 200px;
        line-height: 200px;
        font-weight: 700;
        text-align: center;
        font-size: 50px;
    }
    
    
    @media only screen and (min-width:768px) and (max-width:990px){
    	.mm{
    		background:red;	
    	}
    	
    }
       
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <div class="mm">12</div>
    </body>
    </html>

    【讨论】:

      猜你喜欢
      • 2021-04-11
      • 2014-06-10
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 2018-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多