Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap: What is the correct way to use the `.btn` class within a navbar?

I'm using a navbar for the standard nav stuff and i'd like to include a button for Sign in and Sign up.

The I'm using an a tag with the btn btn-large btn-success classes and by default it appears the navbar does not accommodate the use of nested btns.

The result is something like this:

default without hover

And when hovered over, it comes out as:

hovered

My question is basically: Am i doing this wrong? Is there something I'm missing?

Thought i'd ask before I redefine CSS classes for .btn. within a navbar.

Thanks.

like image 275
Mario Zigliotto Avatar asked Feb 12 '12 21:02

Mario Zigliotto


People also ask

Which Bootstrap CSS class will you use to put the navbar at the top of the page?

Use the . navbar-text class to vertical align any elements inside the navbar that are not links (ensures proper padding and text color).

Which class will you use to make a large button using Bootstrap?

To create a large button, use the . btn-lg class in Bootstrap.

Which class is used to set a button active and inactive in Bootstrap?

Active/Disabled Buttons The class . active makes a button appear pressed, and the disabled attribute makes a button unclickable. Note that <a> elements do not support the disabled attribute and must therefore use the . disabled class to make it visually appear disabled.

Which of the following is correct method to add a success button?

Explanation: There are various styles to add a button in Bootstrap. The syntax for creating a success button in Bootstrap is: <button class = “btn btn-success”> success </button>.


1 Answers

The navbar accommodates buttons without a problem - I have buttons in the navbar without any problems, and I was able to add them to the static navbar example on the Bootstrap page:

Buttons added to the navbar.

The html should be laid out like this:

<div class="navbar navbar-fixed-top active">   <div class="navbar-inner">     <div class="container" style="width: auto;">       <a class="brand" href="#">Project name</a>       <div class="nav-collapse">         <ul class="nav">           ... nav links ...         </ul>         <form class="navbar-search pull-left" action="">           ... search box stuff         </form>         <a class="btn btn-success">Sign in</a>         <a class="btn btn-primary">Sign up</a>       </div>     </div>   </div> </div> 

If you're not using the responsive layout to collapse the navbar on smaller screens, just put your button links one level up, in <div class="container">.

If you're still not finding the problem, try using Chrome's Dev Tools to see what CSS is being applied to the buttons that shouldn't be.

like image 107
Jared Harley Avatar answered Sep 20 '22 13:09

Jared Harley