【问题标题】:What is wrong with these SCSS media queries [duplicate]这些 SCSS 媒体查询有什么问题[重复]
【发布时间】:2015-04-29 10:10:55
【问题描述】:

我正在使用 Twitter Bootstrap 3.3.3 的官方 Sass 端口。

我要做的是在调整窗口大小时缩小导航栏的高度。以下是我的媒体查询,但它们并没有像我期望的那样工作。

$navbar-height: 60px !default;

body {
    padding-top: 70px !important;
}

@media(min-width: 768px) {

    $navbar-height: 70px;

    body {
        padding-top: 80px !important;
    }

}

@media(min-width: 992px) {

    $navbar-height: 80px;

    body {
        padding-top: 90px !important;
    }

}

@media(min-width: 1200px) {

    $navbar-height: 90px;

    body {
        padding-top: 100px !important;
    }

}

【问题讨论】:

    标签: twitter-bootstrap-3 sass media-queries


    【解决方案1】:

    要使其正常工作,请修改 @media 查询中的元素而不是变量。比如……

    $navbar-height: 60px !default;
    
    body {
        padding-top: 70px !important;
    }
    
    @media(min-width: 768px) {
    
        .nav-bar: $navbar-height + 10px;
    
        body {
            padding-top: 80px !important;
        }
    
    }
    
    @media(min-width: 992px) {
    
        .nav-bar: $navbar-height + 20px;
    
        body {
            padding-top: 90px !important;
        }
    
    }
    
    @media(min-width: 1200px) {
    
        .nav-bar: $navbar-height + 30px;    
    
        body {
            padding-top: 100px !important;
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-26
      • 2014-01-29
      • 2013-09-06
      • 2014-01-28
      • 2016-06-29
      相关资源
      最近更新 更多