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; }
}
Related
I used bootstrap header,when it collapse changed to dropdown it moves the below content down, the image moves properly but the text on the image not moving down properly
Image moves down on dropdown but the text remains constant,i need to overlay or move the content down
my html code is:
<nav class="navbar navbar-inverse">
<div class="container-fluid" id="container">
<div class="navbar-header" >
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar" style="background: black !important;"></span>
<span class="icon-bar" style="background: black !important;"></span>
<span class="icon-bar" style="background: black !important;"></span>
</button>
<img src="./assets/logo.png" class="logo" >
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>About</li>
<li class="dropdown">
<a class="dropdown-toggle head-link" data-toggle="dropdown" href="#">Academic <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a class="head-link" href="#">Page 1-1</a></li>
<li><a class="head-link" href="#">Page 1-2</a></li>
<li><a class="head-link" href="#">Page 1-3</a></li>
</ul>
</li>
<li><a class="head-link" href="#">Locations</a></li>
<li><a class="head-link" href="#">Solutions</a></li>
<li><a class="head-link" href="#">Resources</a></li>
<button class="sigin-btn">Signup</button>
</ul>
</div>
</div>
</nav>
<div class="container">
<img src="./assets/Banner.jpg" class="banner">
<span class="cont-line1">Out of focus-</span>
<span class="cont-line2">Achieve with us</span>
</div>
Put this custom css on you .dropdown-item
If u already have some properties , You can manage it
.dropdown-item {
display: block;
max-width: 100%;
padding:0;
clear: both;
font-weight: 400;
color: #212529;
text-align: inherit;
white-space: nowrap;
background-color: transparent;
border: 0;
}
And Add this css on your css file
.navbar-collapse {
max-height: calc(100vh - 60px);
overflow-y: auto;
}
Then it will be fine ...
Hope this works for you
My navbar seems to go out of whack. It's especially evident when I view the site on my mobile device, or just shrink my desktop window.
Below is a link to my site along with the code. I would love for my name to fit between my projects tap on the left and my e-mail and twitter icons on the right. Thank you for your help and time.
http://jocatcreative.com/
(trying to get past stack socials 2 link limit...
imugr dot com/0s4iJyr
imgur dot com/vqjiyEd)
(Edited to include screenshots)
<div class="navbar navbar-default">
<div class="container">
<div class="Heading Tag" align="center"><h2>Jovan S Hernandez</h2></div>
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#example-navbar-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>
<div class="collapse navbar-collapse" id="example-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
<ul class="pull-right">
<i class="fa fa-envelope-o"></i> Email Me
<i class="fa fa-twitter"></i> Twitter
</ul>
</div><!-- .container -->
</div><!-- .navbar -->
DEMO: https://jsbin.com/qufelu/1/
https://jsbin.com/qufelu/1/edit?html,css,output
You were using some incorrect classes, missing tags (on the right aligned stuff), unclosed tag (collapse), and were using an outdated attribute from ancient history ( align="center") Also, you don't need to wrap the name inside a div.
CSS
.custom-navbar {
background: transparent;
border: 0px;
}
#media (max-width:767px) {
.custom-navbar .name {
font-size: 20px;
float: left;
margin: 0;
padding: 15px 0 15px 15px;
}
.custom-navbar .navbar-toggle {
margin: 10px 15px 0 0;
float: right;
}
}
#media (min-width:768px) {
.custom-navbar .navbar-header {
width: 100%;
margin: 0;
}
.custom-navbar .name {
text-align: center;
float: none;
}
}
HTML:
<div class="navbar navbar-default custom-navbar">
<div class="container-fluid">
<div class="navbar-header">
<h2 class="name">Jovan S Hernandez</h2>
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#navbar-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>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="navbar-right nav navbar-nav">
<li><i class="fa fa-envelope-o"></i> Email Me</li>
<li><i class="fa fa-twitter"></i> Twitter</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
</div>
<!-- .navbar-collapse -->
</div>
<!-- .container -->
</div>
<!-- .navbar -->
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;
}
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/
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.