Bootstrap Horizontal Drop Down menu - html

I am trying to have Horizontal drop-down menu like one in here flipkart.com they have floating sidebar menu on hover.
This is my try [With Responsive Design]:-
JSFIDDLE Link - http://jsfiddle.net/QSFPK/
<div class="row-fluid">
<div class="span12">
<div class="span3">
<ul class="nav nav-tabs nav-stacked">
<hr style="margin: -1px;">
<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" title="menu">menu <span class="right-caret right"></span></a>
<ul class="dropdown-menu rightMenu">
<li><a id="logout" href="#">Sign Out</a></li>
</ul>
</li>
<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" title="menu">menu <span class="right-caret right"></span></a>
<ul class="dropdown-menu rightMenu">
<li><a id="logout" href="#">Sign Out</a></li>
</ul>
</li>
<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" title="menu">menu <span class="right-caret right"></span></a>
<ul class="dropdown-menu rightMenu">
<li><a id="logout" href="#">Sign Out</a></li>
</ul>
</li>
<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" title="menu">menu <span class="right-caret right"></span></a>
<ul class="dropdown-menu rightMenu">
<li><a id="logout" href="#">Sign Out</a></li>
</ul>
</li>
<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" title="menu">menu <span class="right-caret right"></span></a>
<ul class="dropdown-menu rightMenu">
<li><a id="logout" href="#">Sign Out</a></li>
</ul>
</li>
<div class="clearFix"></div>
</ul>
</div>
<div class="span9">
<h2>Hello World</h2>
<h2>Hello World</h2>
<h2>Hello World</h2>
<h2>Hello World</h2>
<h2>Hello World</h2>
</div>
</div>
</div>
and here is my CSS :-
.rightMenu {
position:relative;
float:right;
}
.right-caret {
border-bottom: 4px solid transparent;
border-top: 4px solid transparent;
border-left: 4px solid #000000;
display: inline-block;
height: 0;
opacity: 1;
vertical-align: top;
width: 0;
}
.right {
float: right;
}
JSFIDDLE Link - http://jsfiddle.net/QSFPK/
Any help would be great.
Thanks

If you add some sort of class to the list items that have dropdowns, then you can use the css :hover selector to open up the menu with css such as:
li.dropdown:hover .dropdown-menu {
display:block;
}
Here's an edited version of your code, but obviously you'll have to style it so there's no gap causing the mouse to go outside of the <li> item.
http://jsfiddle.net/QSFPK/2/

Related

center multi level dropdown

I've got this working pretty much how I want EXCEPT that the drop down box values are on the left and the rest is properly centered. PLEASE HELP!
I want to keep the level 2 vales to the right of the caret and I've tried everythign I could find online. I'm drawing a total blank.
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle center-block" type="button" data-toggle="dropdown">Pick One
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a tabindex="-1">January</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">Februrary <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://www.amazon.com/" target="_blank">Link</a></li>
</ul>
</li>
<li><a tabindex="-1">March</a></li>
<li><a tabindex="-1">April</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">May <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://www.amazon.com/" target="_blank">link</a></li>
</ul>
</li>
<li><a tabindex="-1">June</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">July<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://www.amazon.com/" target="_blank">link</a></li>
</ul>
</li>
</ul>
</div>
</div>
You would just need to modify your container and dropdown divs:
The container needs to center its content
The dropdown display should be changed so that it doesn't automatically take up all the width within its container.
Here's an example:
<div class="container" style="text-align: center;">
<div class="dropdown open" style="display: inline-block;">
....
</div>
</div>

.btn-group hamburger menu issues and confusion

I'm creating a responsive website, and I'm relatively new to bootstrap. I'm trying to create a responsive navigation that turns into a hamburger menu at less than 1340px. I'm using a split button setup right now, see https://jsfiddle.net/ethacker/u38scspb/, it doesn't really work well, it turns into a scrollable thing. I'd like the dropdown to look something like this on less than 1340px screens.
I'm trying to add the navbar classes (see https://jsfiddle.net/ethacker/d306gphq/1/). When I do this, the navbar hamburger icon doesn't show anymore.
So my questions are :
1. How do I make the hamburger menu icon show?
2. Am I doing this the right way, or is there an easier way?
3. How do I make it look like the above image when viewed on mobile devices/smaller than 1340px screens?
4. How do I trigger the hamburger button at less than 1340px instead of just on mobile?
I'm trying to learn, but I'm just not sure which direction to head in.
My CSS code:
body {
background-image: url('backgroundarrows.png');
}
body > div.container-fluid > header {
background-color: #e9e7ff;
margin-top: 0;
text-align: center;
}
.inline-display {
display: inline;
}
.float-right {
float: right;
}
#logo {
height: 90px;
width: 170px;
}
#search {
margin-right: 1%;
}
.container-fluid {
padding: 0;
}
.content {
padding: 1%;
background-color: #f9fdff;
border: solid thin lightgray;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
margin: 0 1%;
}
section.content {
width: 60%;
}
aside.content {
width: 30%;
text-align: center;
}
.btn {
color: rgb(181,181,225);
}
#my-btn-group{
margin-left: 1%;
}
.mybtngroup {
border-right: solid thin rgb(181,181,225);
border-left: solid thin rgb(181,181,225);
}
.mybtngroup > a.btn.divider {
border-right: solid thin rgb(181,181,225);
}
.heading, div.quip{
font-family: "Monotype Corsiva", cursive;
text-align: center;
}
div.quip, aside > h2.heading{
border-bottom: thin solid grey;
}
div.quip {
font-size: 16px;
}
a{
color: rgb(165, 165, 205);
text-decoration: none;
}
#blogposts {
margin-top: -5%;
}
My HTML:
<div class="container-fluid">
<header class="page-header">
<!-- logo -->
<h1 class="inline-display"><img id="logo" src="mommyinfologo.png"/></h1>
<br/>
<div class="btn-group" id="my-btn-group">
<!-- Home Group -->
<div class="btn-group mybtngroup">
<a class="btn" href="index.php">Home</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>This Mommy's Madness</li>
<li>About Mommy Info</li>
<li>Contact Mommy Info</li>
</ul>
</div>
<!-- Pregnancy group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/pregnancy">Pregnancy</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Trying to Conceive</li>
<li>Fetal Development</li>
<li>Gender Predictions</li>
<li>Labor and Delivery</li>
</ul>
</div>
<!-- All About Baby group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/all-about-baby">All About Baby</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Advice</li>
<li>Guidelines</li>
<li>Milestones</li>
<li>Learning Development</li>
</ul>
</div>
<!-- Health and Nutrition group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/health-and-nutrition">Health and Nutrition</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Pregnancy Nutrition</li>
<li>Breastfeeding</li>
<li>Formula Feeding</li>
<li>Toddler Nutrition</li>
<li>Prenatal Exercise</li>
<li>Postpartum Exercise</li>
<li>Organic DIY Health</li>
</ul>
</div>
<!-- Party Momma group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/party-momma">Party Momma</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Pregnancy Announcement</li>
<li>Gender Reveal</li>
<li>Baby Shower</li>
<li>Birth Announcement</li>
<li>Birthdays</li>
</ul>
</div>
<!-- Stations group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/stations">Stations</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Hospital Bag</li>
<li>Diaper Bag</li>
<li>Changing Station</li>
<li>Baby Gear</li>
</ul>
</div>
<!-- Memory Markers group-->
<div class="btn-group mybtngroup">
<a class="btn" href="/memory-markers">Memory Markers</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Do It Yourself</li>
<li>Buy It</li>
</ul>
</div>
<!-- Reviews group-->
<div class="btn-group mybtngroup">
<a class="btn mycaret" href="/reviews">Reviews</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<ul class="dropdown-menu mylist">
<li>Game Reviews</li>
<li>Gear Reviews</li>
<li>Learning Reviews</li>
</ul>
</div>
<!-- Blog-->
<a class="btn mybtngroup" id="blog" href="/mommy-madness">
Blog
</a>
</div> <!-- closing div#btn-group-justified -->
<input class="float-right" type="text" name="search" id="search" placeholder="Search"/>
This is the code from Bootstrap that makes the navbar collapse when using a tablet or a mobile phone.
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Link <span class="sr-only">(current)</span></li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
<li role="separator" class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
You can read about it more here: http://getbootstrap.com/components/#navbar
You need to include #media query selector into your main.css for the elements to change on specific screen width. For example:
#media (min-width: 768px) {
p { color: red; }
}

Bootstrap brand isn't centering vertically in navbar

i'm having trouble centering my branding logo vertically in the center. As of right now my rendered html looks like this:
<a class='navbar-brand' href='#'>
<img alt="brand" height="200%" src="/assets/logo.png" />
If I don't set the height to a size, it will be the full size of the png. But my branding isn't vertically center with the rest of my navbar.
My css for the navbar-brand looks like this:
.navbar-default .navbar-brand {
color: #777;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
color: #ffffff;
background-color: transparent;
}
What do I need in my css to make this center with the navbar?
This is the full render of the navbar, pulled right from bootstrap docs.
<nav class='navbar navbar-default' role='navigation'>
<div class='container-fluid'>
<!-- Brand and toggle get grouped for better mobile display -->
<div class='navbar-header'>
<button class='navbar-toggle collapsed' data-target='#bs-example-navbar-collapse-1' data-toggle='collapse' type='button'>
<span class='sr-only'>Toggle navigation</span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
</button>
<a class='navbar-brand' href='#'>
<img alt="brand" height="200%" src="/assets/logo.png" />
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class='collapse navbar-collapse' id='bs-example-navbar-collapse-1'>
<ul class='nav navbar-nav'>
<li class='active'>
<a href='#'>Link</a>
</li>
<li>
<a href='#'>Link</a>
</li>
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'>
Dropdown
<span class='caret'></span>
</a>
<ul class='dropdown-menu' role='menu'>
<li>
<a href='#'>Action</a>
</li>
<li>
<a href='#'>Another action</a>
</li>
<li>
<a href='#'>Something else here</a>
</li>
<li class='divider'></li>
<li>
<a href='#'>Separated link</a>
</li>
<li class='divider'></li>
<li>
<a href='#'>One more separated link</a>
</li>
</ul>
</li>
</ul>
<form class='navbar-form navbar-left' role='search'>
<div class='form-group'>
<input class='form-control' placeholder='Search' type='text'>
</div>
<button class='btn btn-default' type='submit'>Submit</button>
</form>
<ul class='nav navbar-nav navbar-right'>
<li>
<a href='#'>Link</a>
</li>
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle='dropdown' href='#'>
Dropdown
<span class='caret'></span>
</a>
<ul class='dropdown-menu' role='menu'>
<li>
<a href='#'>Action</a>
</li>
<li>
<a href='#'>Another action</a>
</li>
<li>
<a href='#'>Something else here</a>
</li>
<li class='divider'></li>
<li>
<a href='#'>Separated link</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
You can try use absolute positioning:
.navbar-brand {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
margin-left: // half the width of your img
}

Bootstrap button text color

I am using the Bootstrap 3 custom buttons but can't for some reason change the brand text color nor the dropdown triangles. I've tried a couple of things, but still no luck...
<div class="container">
<div class="row" style="margin-top: -30px;">
<ul class="nav nav-tabs" role="tablist">
<li class="dropdown" style="margin-right: 70px; margin-left: 60px;" >
<a class="btn btn-inverse :active" data-toggle="dropdown" href="#">
Wristbands <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
...
</ul>
</li>
<li class="dropdown" style="margin-right: 70px;">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Hawaii <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
...
</ul>
</li>
In your example, I don't see any text in the navbar-brand div. Is that what you're talking about?
Anyhow, to answer your question, if you have text in navbar-brand, you'd use something like:
.navbar-default .navbar-brand {
color: blue !important;
}
And for the dropdown arrows, something like:
span.caret {
color: red;
}

twitter bootstrap IE9, nav collapse not pushing rest of content down

Im not sure is this an issue with the content below it, or nav-collapse itself, But the only way I can seem to replicate the issue in firefox is by changing float:left to float:none in the code below. Basically when I toggle the menu the content below it doesnt get pushed down in IE9
.navbar .navbar-inner .nav-collapse.collapse
{
background: #6E2E8F;
border-radius: 5px 5px 5px 5px;
float: left;
height: 0px;
margin-bottom: 15px;
padding: 0;
width: 100%;
}
.navbar {overflow: visible;}
Here is the outputted html...
<div class="navbar">
<div class="navbar-inner">
<a data-target=".nav-collapse" data-toggle="collapse" class="brand visible-phone"> Categories</a>
<a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li>***CONTENT***</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span>Start Shopping
</span><span class="active_downarrow"></span></a>
<span class="sub-menu-response">
<ul class="dropdown-menu" > ***CONTENT*** </ul>
<ul class="dropdown-menu" > ***CONTENT*** </ul>
<ul class="dropdown-menu" > ***CONTENT*** </ul>
<ul class="dropdown-menu" > ***CONTENT*** </ul>
<ul class="dropdown-menu" > ***CONTENT*** </ul>
</span>
</li>
<li> ***CONTENT*** </li>
<li> ***CONTENT*** </li>
<li>***CONTENT*** </li>
</ul>
</div>
</div>
</div>
Here is the link to the site... http://bc_mobile.hailstormcommerce.com/
You can try adding this css class:
.nav-collapse.collapse.in {
height: auto !important;
}
Because when you drop-down the navigation, bootstrap gives it an initial width fixed.