I would like to open a dropdown menu (using Twitter Bootstrap) everytime I click on the brand of my navbar, so I tried this code:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="tabbable">
<div class="dropdown">
<a id="drop1" class="dropdown-toggle" data-toggle="dropdown" href="#menu">
<div class="brand">Brand</div>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<li>Action</li>
</ul>
</div>
<ul class="nav">
<li>
Item
</li>
</ul>
</div>
</div>
</div>
Result: when I click on it, the menu appears, but it's over the brand, not under. How to fix it?
Examples
Standard version [OK]: http://jsfiddle.net/4rdPU/2/
Standard version + div class="brand" [Style problem]: http://jsfiddle.net/4rdPU/1/
Brand version [Wrong menu position]: http://jsfiddle.net/4rdPU/3/
To properly render the dropdown, your brand must be a .nav li element. So just add the .brand class to a standard dropdown.
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="tabbable">
<ul class="nav">
<li class="dropdown">
<a id="drop1" class="dropdown-toggle brand" data-toggle="dropdown" href="#menu">
Brand
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<li>Action</li>
</ul>
</li>
<li>
Item
</li>
</ul>
</div>
</div>
</div>
That will break your brand positioning, but you fan fix it with this simple CSS:
.navbar .brand {
margin-left: 10px; /* This value could be different for another layout */
}
Related
I have a Foundation 5 based site with a nav bar at the top.
Because my menu choices are larger text they overlap the left "Name" section when the screen is made narrower.
Is there a way to control when the nav menu slips into mobile style?
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<div class="logo">
<a href="#">
<img src="mylogo.png"/>
</a>
</div>
</li>
<li class="toggle-topbar menu-icon">
<a href="#">
<span></span>
</a>
</li>
</ul>
<section class="top-bar-section hide-for-medium-down ">
<!-- Right Nav Section -->
<ul class="right">
<li class="active">
<a href="/home/index" class="menuMix">
#*<span class="menuMinor">Home Page</span>*#
<span class="menuMain allCaps">Home</span>
</a>
</li>
<li class="">
<a href="/home/about" class="menuMix">
#*<span class="menuMinor">Who We Are</span>*#
<span class="menuMain allCaps">About</span>
</a>
</li>
<li class="">
<a href="/home/contact" class="menuMix">
#*<span class="menuMinor">Get In Touch</span>*#
<span class="menuMain allCaps">Contact</span>
</a>
</li>
</ul>
</section>
</nav>
If you use SCSS you can try to decrease
$topbar-link-weight: $font-weight-normal;
$topbar-link-font-size: rem-calc(13);
I am using Bootstrap v3 for a layout and have added a dropdown to the navbar but when I add btn-primary the text is black so cannot be seen, if I remove the btn-primary then the corner radius seems to overlap the menu.
Any help is appreciated.
<div class="container">
<div class="col-md-12 column">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="Javascript:void(0);">Title Information </a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown btn-primary">
<a class="dropdown-toggle btn-primary" href="Javascript:void(0);" data-toggle="dropdown">Actions<strong class="caret"></strong></a>
<ul class="dropdown-menu">
<li>
Action 1
</li>
<li>
Action 2
</li>
<li>
Action 3
</li>
<li class="divider"></li>
<li>
Close
</li>
</ul>
</li>
</ul>
</div>
</nav>
<div role="tabpanel" class="col-md-12 column">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Home</li>
<li role="presentation">Profile</li>
<li role="presentation">Messages</li>
<li role="presentation">Settings</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">...</div>
<div role="tabpanel" class="tab-pane" id="profile">...</div>
<div role="tabpanel" class="tab-pane" id="messages">...</div>
<div role="tabpanel" class="tab-pane" id="settings">...</div>
</div>
</div>
</div>
</div>
</div>
some images:
https://www.dropbox.com/s/fuirgtcfc0obl04/Image1.JPG?dl=0
https://www.dropbox.com/s/en0vooc1z99hbkh/Image2.JPG?dl=0
Take out the "btn-primary" but change it to "btn" only, that should fix it.
Remove both btn-primary classes, as these aren't required.
You also have </div> and </nav> closing in the wrong order, and two extra </div> at the bottom of your code.
With the btn-primary removed, and the above fixed, then you get the following:
https://jsfiddle.net/9jym0k8r/
You can customize the style of bootstrap button.
I just added this to change the color of text :
.navbar-default .navbar-nav>li>a {
color: #FFF;
}
Link Demo : http://www.bootply.com/Ukp9KCUuFP
You can also give an "unique id" then customize the style for this button.
<a id="test" class="dropdown-toggle btn-primary" href="Javascript:void(0);" data-toggle="dropdown">Actions<strong class="caret"></strong></a>
css:
#test {
color:white;
}
#test:hover{
color:black;
}
Link : http://www.bootply.com/XWF4x6uhmz
I am building a responsive site with Bootstrap. The site has a fixed nav bar. It works great on desktop. However, when the site is running on a mobile device, the icons in the upper right disappear. My code looks like this:
<div id="nav" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img src="/logo.png">
</div>
<div class="navbar-header navbar-right">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a id="viewButton" data-toggle="tooltip" data-placement="bottom"><span class="glyphicon glyphicon-print"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
<ul class="dropdown-menu" role="menu">
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
How can I right-align buttons in the navbar when in mobile view?
Thanks!
Hi you have to remove the collapse classes from the div.
http://www.bootply.com/F6jMrwYOQQ#
<div id="nav" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img src="/logo.png">
</div>
<div class="navbar-header navbar-right">
<div class="navbar">
<ul class="nav navbar-nav navbar-right">
<li><a id="viewButton" data-toggle="tooltip" data-placement="bottom"><span class="glyphicon glyphicon-print"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
<ul class="dropdown-menu" role="menu">
</ul>
</li>
</ul>
</div>
</div>
</div>
You can try to remove the collapse class here
<div class="navbar-collapse collapse">
I created nav-pills with Twitter bootstrap 3.
Everything is fine except dropdowns.
Documentation shows the layout for tab links, but not for the content: http://getbootstrap.com/components/#nav-dropdowns
I want to show content when user selects one of the dropdown links.
Fiddle is like this: http://jsfiddle.net/mavent/skL5H/3/
<div class="tabbable">
<ul class="nav nav-tabs nav-pills" id="myTab">
<li class="active"> Part 1
</li>
<li class=""> Part 2
</li>
<li class="dropdown"> Activity <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action
</li>
<li>Another action
</li>
</ul>
</li>
</ul>
<br>
<div class="tab-content">
<div class="tab-pane active" id="tab1">aaaaaaaaaaaa</div>
<div class="tab-pane" id="tab2">bbbbbbbbbbbb</div>
<div class="tab-pane" id="tab3">cccccccccccccc</div>
<div class="tab-pane" id="tab4">dddddddddddddd</div>
</div>
</div>
Add data-toggle="dropdown" to the links in the .dropdown-menu.
http://jsfiddle.net/skL5H/5/
I am using the Bootstrap 3.0 framework and Modern Business theme (http://startbootstrap.com/modern-business). When using the default Modern Business nav settings, the main menu dropdowns work brilliantly as they should on mobile devices. However, when I change the menu to be "nav-justified" in the HTML code (using Bootstrap's "nav-justified" CSS class), the menu does not work as expected.
When you tap any menu item with dropdowns, it shows a navigation dropdown on the far left side, which runs outside of the parent CSS frame:
I am also using the Sticky Nav solution found here: How to use the new affix plugin in twitter's bootstrap 2.1.0?
Here is my HTML code for the menu:
<nav class="navbar navbar-inverse" role="navigation">
<div id="nav-wrapper">
<div id="nav" class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="span12">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div> <!-- navbar-header -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav nav-justified">
<li>About</li>
<li>Services</li>
<li>Contact</li>
<li class="dropdown">
Portfolio <b class="caret"></b>
<ul class="dropdown-menu">
<li>1 Column Portfolio</li>
<li>2 Column Portfolio</li>
<li>3 Column Portfolio</li>
<li>4 Column Portfolio</li>
<li>Single Portfolio Item</li>
</ul>
</li>
<li class="dropdown">
Blog <b class="caret"></b>
<ul class="dropdown-menu">
<li>Blog Home 1</li>
<li>Blog Home 2</li>
<li>Blog Post</li>
</ul>
</li>
<li class="dropdown">
Pages <b class="caret"></b>
<ul class="dropdown-menu">
<li>Full Width Page</li>
<li>Sidebar Page</li>
<li>FAQ</li>
<li>404</li>
<li>Pricing Table</li>
</ul>
</li>
</ul>
</div> <!-- collapse -->
</div> <!-- span12 -->
</div> <!-- container -->
</div> <!-- navbar-inner -->
</div> <!-- navbar -->
</div> <!-- nav-wrapper -->
</nav>
And here is the script I have at the bottom of my HTML:
<script>
$(function() {
$('#nav-wrapper').height($("#nav").height());
$('#nav').affix({
offset: { top: $('#nav').offset().top }
});
});
</script>
Here, also, is the obligatory JSFiddle to examine (JS and CSS code linked in the JSFiddle panel on the left): http://jsfiddle.net/L94Mj/
I'm sure I'm somehow dancing around the answer, but this thing has had me stumped for two days now, and I need a fresh brain to look at things. I'm happy to provide whatever extra code is needed to help find the answer.