Decreasing height of bootstrap 3.0 navbar

前端 未结 9 1812
一向
一向 2020-12-02 04:23

I am trying to decrease bootstrap 3.0 navbar height which is used with fixed top behavior. Here i am using code.

HTML

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 05:08

    Wanted to added my 2 pence and a thank you to James Poulose for his original answer it was the only one that worked for my particular project (MVC 5 with the latest version of Bootstrap 3).

    This is mostly aimed at beginners, for clarity and to make future edits easier I suggest you add a section at the bottom of your CSS file for your project for example I like to do this:

    /* Bootstrap overrides */
    
    .some-class-here {
    }
    

    Taking James Poulose's answer above I did this:

    /* Bootstrap overrides */   
    .navbar-nav > li > a { padding-top: 8px !important; padding-bottom: 5px !important; }
    .navbar { min-height: 32px !important; }
    .navbar-brand { padding-top: 8px; padding-bottom: 10px; padding-left: 10px; }
    

    I changed the padding-top values to push the text down on my navbar element. You can pretty much override any Bootstrap element like this and its a good way of making changes without screwing up the Boostrap base classes because the last thing you want to do is make a change in there and then lose it when you updated Bootstrap!

    Finally for even more separation I like to split up my CSS files and use @import declarations to import your sub-files into one main CSS File for easy management for example:

    @import url('css/mysubcssfile.css');
    

    note: if you're pulling in multiple files you need to make sure they load in the right order.

    Hope this helps someone.

提交回复
热议问题