仅在折叠时更改Bootstrap汉堡颜色

时间:2016-05-15 20:55:05

标签: css twitter-bootstrap

当页面首次打开时,我使用bootstrap来显示透明导航,但是一旦用户向下滚动并且导航栏折叠,它就会变为白色背景。

我用它来改变背景颜色:

.top-nav-collapse {
  background-color: #FFFFFF !important;
}

我从广泛的谷歌搜索中了解到,这一般会改变汉堡包图标的颜色:

.navbar-default .navbar-toggle .icon-bar {
  background-color: black;
}

然而,我似乎无法在崩溃时改变颜色。这是我的导航条形码:

    <nav class="navbar  navbar-fixed-top z-depth-1" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand waves-effect waves-light pull-left" href="/"><%= image_tag 'Flame.png', style: "height: 100%"%></a>
            </div> <!-- navbar-header -->

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                <ul class="nav navbar-nav">
                    <li><a href="#" class="waves-effect waves-light">Workouts <span class="sr-only">(current)</span></a></li>
                    <li><%= link_to 'Blog', posts_path, class:"waves-effect waves-light" %></li>
                    <li><a href="#" class="waves-effect waves-light">Equipment</a></li>
                    <li><a href="#" class="waves-effect waves-light">About Us</a></li>
                </ul>
            </div> <!-- navbar collapse -->
        </div> <!-- container-fluid -->
    </nav>

任何人都可以对此有所了解吗?

1 个答案:

答案 0 :(得分:1)

很难完全理解你的要求,但我认为你只是在寻找这个

Content

如果按原样使用,则可能需要public class RadioBtnToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string input = value as string; switch (input) { case "1": return Brushes.Red; default: return Brushes.SlateBlue; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } } 任何属性来覆盖Bootstrap默认值。否则,为选择器添加任何必要的特异性(即.navbar-toggle.collapsed .icon-bar { ... } ),你应该是好的。