Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter BootStrap TopBar and DropDown Menu

I am trying to build a topbar that has some links on the left and to the right, there will be a Login Link which would open the Login Form in a DropDown. I also want that the Login form should behave like a selected Tab when clicked (or when the dropdown is open)

My code looks like this :-

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
    <div class="container">
        <ul class="nav">
            <li><a href="#">Home</a></li>
            <li><a href="#">Section1</a></li>
            <li><a href="#">Section2</a></li>
        </ul>

        <ul class="nav nav-tabs pull-right signin-menu">
            <li class="dropdown" data-dropdown="dropdown"><a href="#" data-toggle="dropdown" class="login-link dropdown-toggle">Login</a>
                <ul class="dropdown-menu" id="signin-dropdown">
                    <li>
                        <form>....</form>
                    </li>
                </ul>
            </li>   
        </ul>           
    </div>
</div>

I've got 2 lists, one of them to the right as I wanted it to behave like tabs. My problem is that I can't remove the little arrow that points to the Login Link when the dropdown is open. I want it to look like a selected Tab with dropdown below it, without the pointing arrow.

Also, the tab looses it's rounded corners when selected. I am sure it's a CSS issue but not sure where to look for it..

Any ideas?

P.S. I am on BootStrap v2.0.1

like image 566
Anuj Gakhar Avatar asked Feb 29 '12 18:02

Anuj Gakhar


People also ask

How do I add a drop down menu in Bootstrap?

To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.

Why is my dropdown menu not working Bootstrap?

Why is my drop down menu not working in bootstrap? Solution : The dropdown should be toggled via data attributes or using javascript. In the above program, we have forgotten to add a data attribute so the dropdown is not working. So add data-bs-toggle="dropdown" to toggle the dropdown.

How do you open Bootstrap dropdown menu on hover rather than click?

Answer: Use the jQuery hover() method By default, to open or display the dropdown menu in Bootstrap you have to click on the trigger element. However, if you want to show the dropdown on mouseover instead of click you can do it with little customization using the CSS and jQuery.

How do I change the position of a drop down menu in Bootstrap?

Use data-offset or data-reference to change the location of the dropdown.


1 Answers

The arrow is added by the bootstrap by using a pseudo-element, you can negate that feature on the "login" portion of your code by targeting that unique class you added, to leave the default behavior untouched for other menu elements. This way also makes for a no-fuss bootstrap update.

You can remove the dropdown arrow on the login box by adding display:none to the corresponding pseudo-class like so:

CSS

.signin-menu .dropdown-menu:before {
    display: none;
}

.signin-menu .dropdown-menu:after {
    display: none;
}

Quick Demo, edit here.

like image 92
Andres Ilich Avatar answered Oct 22 '22 09:10

Andres Ilich