Style of Twitter's Bootstrap 3 navbar

16,849

Just like buttons and panel a navbar will have two classes (see: https://github.com/twbs/bootstrap/issues/10332). The first class (.navbar) will set the structure. The second class will set the styling. By default there will be two classes for styling: .navbar-default and .navbar-inverse. To change the style of your navbar you have to change the styles of these styling classes. The best way to do this is using Less and recompile Bootstrap.

Using Less

The variables for .navbar-default and .navbar-inverse are set in variables.less and used by navbar.less. To define a custom navbar style you could modify the variable for .navbar-default or .navbar-inverse and reuse this classes. If you don't want to change the original code. Create an customnavbar.less file (don't forget ti import this in bootstrap.less) and copy the .navbar-default part from navbar.less to this file. Rename and set the variables. B.e. see here: Change twitter bootstrap 3.0 navbar class background color in less to set the background to blue.

Using CSS

Define your css just like .navbar-default. To change the style. B.e. for <nav class"navbar navbar-custom"> and set background to blue;

.navbar-custom { background-color: #0000FF;}

For more styles and easy styling see: http://twitterbootstrap3navbars.w3masters.nl/

Share:
16,849
Bass Jobsen
Author by

Bass Jobsen

Author of Less Web Development Essentials http://www.packtpub.com/less-web-development-essentials/book and Less Web Development Cookbook https://www.packtpub.com/web-development/less-web-development-cookbook. Currently, i write a blog (http://bassjobsen.weblogs.fm/), program LBS for mobile devices (http://www.gizzing.nl), make cool websites (such as http://www.streetart.nl/), and counsel in setting up the technical environments and requirements. You can also check out my Bootstrap WordPress Starters Theme (JBST) and other projects at GitHub at https://github.com/bassjobsen. Also try: http://twitterbootstrap3buttons.w3masters.nl/ and http://twitterbootstrap3navbars.w3masters.nl/ Twitter: @bassjobsen Google+: http://google.com/+BassJobsen

Updated on June 21, 2022

Comments

  • Bass Jobsen
    Bass Jobsen almost 2 years

    Howto change the styles of navbars in Twitter's Bootstrap 3 using Less or css? Using different styles as provide by the navbar-default and navbar-inverse classes.