Bootstrap 3 navbar and collapse menu different background colors?

后端 未结 2 1303
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 12:05

I would like to have the Navbar background be a different color than the background of the collapsed menu.

相关标签:
2条回答
  • 2021-02-07 12:38

    I believe I found an answer to this, but would appreciate any further comments or alternate solutions, as this seems to be a bit hacky...

    .navbar {background-color: #8e181b;}
    .navbar-default .navbar-nav > li > a, .navbar-default .navbar-brand {color: #f1f1f1;}
    .navbar-default .navbar-nav > li > a:hover, 
    .navbar-default .navbar-nav > li > a:focus {color: #f1f1f1; background-color: #b27677;}
    
    @media only screen and (max-width: 766px) {
    .collapsing, .in {background-color: #f7f7f7;}
    .collapsing ul li a, .in ul li a {color: #555!important;}
    .collapsing ul li a:hover, .in ul li a:hover {color: #f1f1f1!important;}
    }
    

    Here is the jsfiddle: http://jsfiddle.net/vp7XS/

    0 讨论(0)
  • 2021-02-07 12:44

    You can do it like this

    .navbar-default {
        border-color: white;
        background-color: #FF2032;
     }
    
     @media only screen and (max-width: 768px) {
        .navbar-default .navbar-collapse {
            border-color: white;
            background-color: #e87373;
         } 
     }
    

    check this fiddle , i hope it answers your question

    0 讨论(0)
提交回复
热议问题