I have following menu
(i don't know why it doesn't show the 3 icon bars when its collapsed but they are there so you can hover over it and click it it will open up)
code
https://jsfiddle.net/x4mcq4h7/13/
My issue is that when I hover over the list item (yogaclasses) that has a submenu (yogastyles), I can't actually click on it because it goes away whenever i go on it with my mouse.
I have tried to change around the CSS I have but with no luck and I don't know what or where I should look for changing this neither...
I would like it to behave like when you go over the parent list item, it shows the submenu over the underlying one (event menu) so that you can't see the event menu text, and well then of course actually be able to click on it :)
If someone can help me in the right direction I would really appreciate it!
You need to add z-index that works fine and make that link clickable,
.dropdown-content {
display: none;
position: absolute;
background-color: #CECB26;
min-width: 180px;
border-radius: 4px;
z-index:9;/*Add this*/
}
Check this updated jsFiddle
By default the bars & button border have a transparent color, you need to assign them a color, add the following CSS:
.navbar-toggle .icon-bar {
background: #fff;
}
.navbar-toggle {
border: 1px solid #fff;
}
Have a look at the snippet below:
a,
#home-slider .caption h1 span,
#twitter-carousel .item span,
#footer .footer-bottom,
#single-portfolio .close-folio-item:hover,
.single-table.featured .btn.btn-primary,
.contact-info ul li a:hover,
#footer .footer-bottom a {
color: #8E8C21;
}
.btn.btn-primary:hover {
background-color: lightgoldenrodyellow;
color: #CACA4D;
border-color: #CACA4D;
}
.btn-submit {
background-color: transparent;
border: 1px solid #CACA4D;
}
.btn-submit:hover {
background-color: #CACA4D;
}
.btn-primary:hover {
background-color: #8E8C21;
border-color: #CACA4D;
}
a:hover, a:focus {
color: #CACA4D; /*#027db3;*/
}
.main-nav,
.service-icon,
.progress-bar.progress-bar-primary,
.single-table.featured,
.btn.btn-primary,
.twitter-icon .fa-twitter,
.twitter-left-control:hover, .twitter-right-control:hover,
.post-icon,
.entry-header .date:after,
.btn-loadmore:hover,
#footer,
.caption .btn-start:hover,
.left-control:hover,
.right-control:hover,
.folio-overview a:hover {
background-color: #C9C903;
}
/*.main-nav{
min-height:60px;
}*/
.main-nav ul li a {
border-radius: 4px;
height: 50px;
}
.main-nav ul li a:hover {
background-color: #F7F7CD;
color: #CACA4D;
}
.twitter-left-control:hover,
.twitter-right-control:hover,
.btn-loadmore:hover {
border: 1px solid #C9C903;
}
.caption .btn-start:hover,
.left-control:hover,
.right-control:hover {
border-color: #CACA4D; /*#028fcc;*/
}
.twitter-icon .fa-twitter:after {
border-color: #CACA4D;
transparent transparent;
}
/*------------------------------------------*/
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #CECB26;
min-width: 180px;
border-radius: 4px;
}
.dropdown-content a {
display: block;
text-align: center;
}
.dropdown:hover .dropdown-content {
display: block;
}
.navbar-toggle .icon-bar {
background: #fff;
}
.navbar-toggle {
border: 1px solid #fff !important;
}
.dropdown-content {
width: 100%;
z-index: 10;
}
.dropdown-content a {
text-align: left;
padding: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="main-nav">
<div class="container">
<div class="navbar-header">
<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">
<ul class="nav navbar-nav navbar-right">
<li class="scroll active"><i class="fa fa-home fa-lg" aria-hidden="true"></i> Home</li>
<li class="scroll dropdown">
<i class="fa fa-universal-access fa-lg"></i>Yogaclasses
<div class="dropdown-content">
<i class="fa fa-universal-access fa-lg" aria-hidden="true"></i> Yogastyles
</div>
</li>
<li class="scroll"><i class="fa fa-calendar fa-lg" aria-hidden="true"></i> Events</li>
<li class="scroll"><i class="fa fa-phone-square fa-lg" aria-hidden="true"></i> Contact</li>
</ul>
</div>
</div>
</div><!--/#main-nav-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
Hope this helps!
Related
I have a navbar in asp.net mvc web application and when I hover on it I Want background to occupy all space but at some of the list Items it does not occupy spaces at the bottom as You can see in the image
li elements of services, signup and login occupying all spaces at the bottom but Home and aboutUs are not. i tried margin:0; at li element but nothing happens.
.navbar {
font-size: 1.25em !important;
box-shadow: 0px 0px 3px 0.5px black;
border : none;
}
.navbar-inverse {
background-color: #00ff99 !important;
}
.navbar-toggle {
background-color: #00804d;
}
.navbar-inverse .navbar-brand {
color: #000099 !important;
font-family: 'Brush Script MT' !important;
font-size: 1.50em !important;
font-weight: 400 !important;
text-shadow: 5px 5px 5px black !important;
}
.navbar-nav li{
margin:0;
}
.navbar-inverse .navbar-nav > li > a {
color: black;
}
.navbar-inverse .navbar-nav > li > a:hover, .Dropdown-btn:hover, .Dropdown-btn:focus {
/*background-color: #8080ff;*/
background-color: rgba(128, 128, 255,0.5) !important;
color: white important;
}
.glyph-pad {
left: -4px;
top: 4px;}
.Dropdown-btn {
cursor: pointer;
font-size: inherit;
border: none;
outline: none;
color: black;
font-family: inherit;
background-color: inherit;
padding: 13px 13px;
margin: 0;
}
.dropdown-menu {
display: none;
position: absolute;
background-color: #00ff99;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-menu > li > a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
ul.dropdown-menu > li > a {
color: black !important;
}
ul.dropdown-menu > li > a:hover {
background-color: rgba(128, 128, 255,0.5) !important;
color: white !important;
}
.dropdown-menu > li > a:hover {
/*background-color: #8080ff;*/
background-color: rgba(0, 255, 153,0.8);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
E-HealthCare
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
Home
</li>
<li>
<div class="dropdown">
<button class="Dropdown-btn btn-block text-left dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="false">
Services
<span class="caret"></span>
</button>
</div>
</li>
<li>About Us</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<Span class="glyphicon glyphicon-user"></Span> Sign Up
</li><li>
<Span class="glyphicon glyphicon-log-in"></Span> Login
</li>
</ul>
</div>
</div>
</div>
This is working codepen link
I'm working on a profile website for myself and have a 'decent' concept up and running.
However it seems as if my navbar's data-spy either isn't firing off or if there is something wrong with my html / css.
This is a pen with the html / css.
This is the body (relevant data-spy reference):
<body data-spy="scroll" data-target="#navbar" data-offset="50">
This is how I've set up the navbar:
<nav id="navbar" class="collapse navbar-collapse">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#navBar-target" class="navbar-toggle">
<span class="icon-bar"> </span>
<span class="icon-bar"> </span>
<span class="icon-bar"> </span>
</button>
</div>
<div class="collapse navbar-collapse" id="navBar-target">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#top" > About </a>
</li>
<li>
<a href="#portfolio" > Portfolio </a>
</li>
<li class>
<a href="#contact" > Contact </a>
</li>
</ul>
</div>
</nav>
And here is some of the relevant css:
.navbar-default .navbar-nav>li>a:focus,
.navbar-default .navbar-nav>li>a:hover {
color: #333;
background-color: black;
}
.navbar-nav>li>a {
color: #000000 !important;
}
#navbar {
margin: 12px 0;
}
.navbar-default .navbar-toggle {
border-color: #ddd;
}
.navbar-toggle {
position: relative;
float: right;
padding: 9vw 10vw
margin-top: 8vw;
margin-right: 15vw;
margin-bottom: 8vw;
background-color: transparent;
background-image: none;
border: 1vw solid transparent;
border-radius: 4vw;
}
.navbar-default .navbar-collapse {
border-color: #e7e7e7;
}
.nav>li {
height: 100%;
text-transform: uppercase;
font-weight: bold;
letter-spacing: 2px;
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
}
.nav>li>a:focus,
.nav>li>a:hover {
text-decoration: none;
color: #722872;
background-color: #FFFFFF;
}
.nav>li a:hover {
color: #722872;
background: #FFFFFF;
box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.1);
}
As mentioned, a full working example is on the code-pen
Seems Bootstrap doesn't include a default style for the active nav element. Need to create a style for .navbar-nav>.active>a
I am building this website
torgoborudovanie.com
I have a collapsing navbar build with bootstrap.But when I try to resize the window I get something like this :
As you can see (and you can actually try it ) nav bar now has 2 lines and it looks wired (the actual problem is that it looks like this on Iphone and Ipad) Then you can resize it a little bit more and it gets collapsed as I want.
You can see the code by simply viewing html code in developer tools.
So I will not post it here to make qustion clean and small.But if you want I can post the code here too=)
I ended up with this (quite shitty to be fair workaround)
On page load if I have window.width less than 1200px I just hide long text.
function hideSlogan() {
if($(window).width() <1200) {$('.slogan').hide()}
};
hideSlogan();
Go to the CSS rules starting at the MOBILE NAV comment; these are the rules you can adjust to make the navbar collapse at different breakpoints.
On a sidenote, there is one extra, broken list tag in the nav and with the positioning of Надежный партнер - качественные решения! inside your navbar-collapse div you'll the following behavior:
If you expand the menu when it's in the mobile and then expand the viewport your navbar will revert to the line-height: 60px unless the browser is refreshed. Might not matter but since you're trying to change the collapse breakpoint it's worth mentioning.
**I also moved the inline styles with the rest of the CSS Rules.
#import url(http://fonts.googleapis.com/css?family=Open+Sans:400, 700, 800);
#import url(http://fonts.googleapis.com/css?family=Libre+Baskerville:400italic);
* {
margin: 0;
padding: 0px;
font-family: 'Open Sans', sans-serif;
}
body {
background: #fff;
margin: 0;
color: #42413e;
padding-top: 50px;
}
/* BOOTSTRAP MODIFICATION */
.navbar-right a .btn-orange {
margin-top: -5px;
}
.btn-orange {
background: #f27242;
border-radius: 2px;
color: white;
font-size: 12px;
font-weight: 700;
}
.btn-orange:hover {
background: #e16a3e;
color: white;
}
.navbar-default .navbar-brand {
height: 50px;
padding: 10px 15px;
font-size: 20px;
line-height: 22px;
font-weight: 700;
}
.navbar.navbar-default {
background-color: #ffffff;
border-color: #e7e7e7;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #f27242;
background-color: transparent;
}
.navbar-default .navbar-nav > li > a {
color: #ccc;
}
.navbar-default .navbar-right {
padding-top: 5px
}
.navbar-default li.dropdown a {
color: black;
}
.navbar-default span.head-title {
line-height: 60px;
}
.navbar-default .navbar-right .dropdown-menu {
right: auto;
left: 0;
}
.navbar-right li.contact-info a {
color: #42413e;
}
/****MOBILE NAVBAR******/
#media (max-width: 1200px) {
.custom-navbar .navbar-header {
float: none;
}
.custom-navbar .navbar-left,
.custom-navbar .navbar-right {
float: none !important;
}
.custom-navbar .navbar-toggle {
display: block;
}
.custom-navbar .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
overflow-x: hidden;
}
.custom-navbar.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.custom-navbar .navbar-collapse.collapse {
display: none!important;
}
.custom-navbar .navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.custom-navbar .navbar-nav > li {
float: none;
}
.custom-navbar .navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
.custom-navbar .collapse.in {
display: block !important;
}
.custom-navbar .navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.custom-navbar .navbar-brand {
height: 55px;
padding: 10px 15px;
font-size: 20px;
line-height: 22px;
font-weight: 700;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<nav class="navbar navbar-default custom-navbar navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Переключить навигацию</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="http://www.torgoborudovanie.com/assets/img/logo1.png" width="140">
</a>
</div>
<div class="collapse navbar-collapse"><span class="head-title">Надежный партнер - качественные решения!</span>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> Каталог <span class="caret"></span>
<ul class="dropdown-menu">
<li>Стеллажи
</li>
<li>Торговая мебель
</li>
<li>Тележки и корзины
</li>
<li> Кассовые боксы
</li>
<li>Холодильное оборудование
</li>
<li role="separator" class="divider"></li>
<li>Условия доставки
</li>
</ul>
</li>
<li class="contact-info">
<i class="fa fa-phone "></i> 8 (343) 3448090
</li>
<li class="contact-info">
<i class="fa fa-envelope"></i> info#optimagp.ru
</li>
<li>
<a href="#f">
<button class="btn btn-sm btn-orange" type="button">Заказать звонок</button>
</a>
</li>
</ul>
</div>
</div>
</nav>
you need to change your breakpoint, when the navbar gets collapsed...
so for example, this should work:
#media only screen and (min-width: 1200px) {
.collapse {
display: block;
}
.navbar-toggle {
display: none;
}
}
#media only screen and (max-width: 1200px) {
.collapse {
display: none;
}
.navbar-toggle {
display: block;
}
}
because it floats (because its so long) after 1200px width...
** sorry, i made a mistake... try it now :) **
I have a Bootstrap 3 navbar. Everything works fine on mobile but at desktop size the "mobile" collapse version of the navbar flickers down when a nav link is clicked. I just don't want to be able to see this on the desktop.
You can view a bootply here.
I am fairly new to web development so I apologize if my code is unorganized or sloppy. The code is...
/* CSS used here will be applied after bootstrap.css */
.navbar {
height: 110px;
background-color: #f7f7f7;
width: 100%;
border-color: #f7f7f7;
}
.navbar-logo {
margin-top: 10px;
margin-left: 45px;
}
.navbar-social {
margin-top: 10px;
}
.navbar-social i {
float: left;
background: #ffffff;
color: #707070;
width: 30px;
height: 30px;
border: 1px solid #909090;
border-radius: 20px;
text-align: center;
margin-right: 10px;
padding-top: 10px;
}
.navbar-social > p {
float: right;
text-align: right;
color:#FF344E;
}
.navbar .nav-pills>.active>a:hover,.navbar .nav-pills>li>a:hover, .navbar .nav-pills>li>a:focus {
background-color: #f60756;
}
.navbar .nav-pills>.active>a,.navbar .nav-pills>.open>a,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover, .navbar .nav-pills>.open>a:focus {
background-color: #f60756;
}
.dropdown-menu {
background-color: #f7f7f7;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
background-color: #f60756;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
background-image: none;
}
.navbar .navbar-brand {
color: #000000;
}
.navbar .navbar-brand:hover {
color: #FFFFFF;
}
/* fills in background on hamburger menu */
.navbar-collapse > ul {
background-color: #f7f7f7;
}
/* hamburger menu list */
.navbar .nav-pills>li {
margin: 10px;
font-size: 18px;
background-color: #f7f7f7;
}
/* hamburger menu list item */
.navbar .nav-pills>li>a {
color: #000000;
background-color: #f7f7f7;
}
.navbar .nav-pills .open .dropdown-menu>li>a, .navbar .nav-pills .open .dropdown-menu {
background-color: #f7f7f7;
color:#ffffff;
}
.navbar .nav-pills>li>a:hover, .navbar .nav-pills>li>a:focus {
color: #ffffff;
background-color: #f60756;
}
.navbar .nav-pills>.active>a,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover, .navbar .nav-pills>.open>a:focus {
color: #ffffff;
background-color: #f60756;
}
.navbar .nav-pills>.active>a:hover, .navbar .nav-pills>.active>a:focus {
color: #707070;
background-color: #f60756;
}
.navbar .dropdown-menu {
background-color: #f7f7f7;
color: #ffffff;
}
.dropdown-menu>li>a {
color: #333333;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
color: #FFFFFF;
}
.navbar .nav-pills>.dropdown>a .caret {
border-top-color: #999999;
}
.navbar .nav-pills>.dropdown>a:hover .caret {
border-top-color: #999999;
}
.navbar .nav-pills>.dropdown>a .caret {
border-bottom-color: #999999;
}
.navbar .nav-pills>.dropdown>a:hover .caret {
border-bottom-color: #999999;
}
/* hamburger menu colors */
.navbar .navbar-toggle {
border-color: #f60756; /* Change border color around this buttons */
background: #f60756; /* Change background for button itself */
}
.navbar .navbar-toggle .icon-bar {
background: #ffffff; /* Change color for horizontal lines */
}
.navbar-collapse.in {
overflow-y: none;
}
<div class="navbar navbar-fixed-top" role="banner">
<a href="./" class="col-xs-2 col-sm-2 col-md-2 navbar-logo">
<img alt="Brand" src="img/" height="100" width="100">
</a>
<div class="col-xs-6 col-xs-offset-1 col-sm-6 col-md-6 col-md-offset-0 col-lg-6 navbar-social">
<i class="fa fa-facebook"></i>
<i class="fa fa-twitter"></i>
<i class="fa fa-google-plus fa-lg"></i>
<!--TODO check vimeo for removal
<i class="fa fa-vimeo"></i> -->
<p>555.555.5555</p>
</div>
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-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>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="col-xs-6 col-xs-offset-8 col-sm-12 col-md-9 col-md-offset-1 nav navbar-nav nav-pills">
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#whyRadicalNav">Why Radical?</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#whyGiraffeNav">Why Giraffe?</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#towerNav">Tower</a>
</li>
<li>
Stories
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#contactNav">Contact</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#">Blog</a>
</li>
</ul>
</nav>
</div>
That is because you are targeting navbar-collapse every time a link is clicked. Exactly why the navbar is behaving funny:
Bootply Link
instead of this:
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#contactNav">Contact</a>
</li>
go for this (do this for all the links):
<li>
Contact
</li>
<li>
Why Radical?
</li>
<li>
Why Giraffe?
</li>
I am trying to push down my content whenever a user selects a links with a drop down menu. However, when clicked the dropdown goes over the content rather than pushes it down.
I have tried using position: relatives/position: absolute, etc to achieve some sort of desired result, but no such luck. I have seen other similar questions pertaining to this problem but it still has not helped me.
Any help in solving this problem would be greatly appreciated.
My HTML and CSS
body {
margin: 0;
padding: 0;
font-family: "Helvetica", "Arial", sans-serif;
font-weight: 500;
font-style: normal;
font-size: 12px;
line-height: 1.5;
}
.navbar-default {
background-color: #ffffff;
}
.navbar {
min-height: 65px;
padding-top: 5px;
margin-bottom: 0px;
border-bottom: solid 2px #eee;
}
.navbar-header {
margin-top: -12px;
}
.navbar-brand {
padding-top: 0px !important;
}
/* for button placement*/
.navbar-toggle {
margin-top: 26px;
}
/*for collapsed navbar*/
.navbar-collapse {
margin-top: 12px;
}
.site-logo {
max-width: 135px;
min-width: 120px;
}
.navbar-default .navbar-nav>li>a {
text-transform: uppercase;
background-color: #ffffff !important;
color: #333333;
}
.navbar-default .navbar-nav>li>a:hover {
color: #3381d0;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
background-color: #ffffff;
border-bottom: 2px solid #ff5d1c;
color: #ff5d1c;
bottom: -2px;
}
.nav>li {
position: static !important;
}
/* For navbar dropdown*/
.navbar .dropdown-menu {
min-width: 1349px;
width: 100%;
height: 120px;
margin-top: 51px;
z-index: 1;
left: 0;
text-align: center;
padding-right: 10px;
position: absolute;
list-style-type: none;
border-top: 2px solid #ff5d1c;
border-bottom: 2px solid #333333;
border-right: #ffffff;
border-radius: 0;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
border-left: 0;
background-color: #337ab7;
}
.dropdown-menu {
padding-left: 10px;
padding-right: 10px;
position: relative;
list-style-type: none;
}
.navbar .dropdown-menu li {
margin: 0;
padding: 0;
display: inline-block;
}
.dropdown-menu>li>a {
color: #ffffff;
line-height: 75px;
padding: 3px;
}
.dropdown-menu>li>a:hover {
color: #333333 !important;
}
.dropdown-menu>li>a:hover {
color: #ffffff;
background-color: #337ab7;
}
.m-pub {
display: inline-block;
margin: 3px 40px 0;
font-size: 13px;
font-weight: 400;
text-transform: uppercase;
letter-spacing: .14em;
color: white;
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
position: relative;
}
.m-pub:after,
.m-pub:focus {
color: #ffffff;
background-color: #337ab7;
}
.dropdown-menu li .m-pub:hover:after {
content: '';
position: absolute;
left: 50%;
margin-left: -10px;
margin-top: 55px;
border-left: 0;
border-bottom: 17px solid transparent;
border-top: 17px solid transparent;
border-left: 14px solid #333333;
transform: rotate(-90deg);
background: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" crossorigin="anonymous"></script>
<body>
<nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#">
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav" id="nav">
<li class="nav-link active">Link</li>
<li class="nav-link">Link</li>
<li class="nav-link">Link</li>
<li class="dropdown">
Drop-Down Menu<i class="fa fa-angle-down flipped"></i>
<ul class="dropdown-menu" id="menu">
<li class="nav-link">
<i class="fa fa-microphone fa-2x"></i>Option
</li>
<li class="nav-link">
<i class="fa fa-newspaper-o fa-2x"></i>Option
</li>
</ul>
</li>
<li class="nav-link">Link</li>
<li class="nav-link">Link</li>
</ul>
</div>
</div>
</nav>
<div class="container" style="background: red;height:100px; width: 100%;">
</div>
</body>
I have provided a jsfiddle:
JSFiddle
Your issue, as you suspected, is the positioning. Unfortunately, if you use position: absolute, .dropdown-menu is removed from the flow of the document, winding up on top of anything beneath it rather than moving it out of the way. If you use position: relative it forces it's parent to resize messing up your menu. As far as I know there is no solution to this problem with pure CSS. However, there is a few solutions with javascript, and since JQuery is already being used by bootstrap, we can just use that.
In order to move the content down when dropdown-menu is clicked you need to change either .container, the content, itself, or the parent/grandparent element that the dropdown-menu is relative to. I chose to add margin-bottom the grandparent, which in this case, is the nav element. You could just as easily add margin-top to .container. Either way you need to set the margin equal to the height of .dropdown-menu which is set to 120px. I created the following rule to achieve this:
nav.navbar.open {
margin-bottom: 120px;
}
The extra class .open will be added by JQuery when li.dropdown is clicked. I just used this quick bit of JQuery to acomplish this:
$("li.dropdown").click(function() {
$("nav.navbar" ).toggleClass( "open");
});
That's all that is needed. When li.dropdown is clicked a .open is added to the nav element which increases its bottom margin to the same height of .dropdown-menu. The margin doesn't affect .dropdown-menu since it's absolutely positioned and instead only pushes down .container just as if .dropdown-menu was not removed from the document flow. The reason for using li.dropdown and not #menu-trigger (the link itself) is because if you use the link, and then click on .dropdown-menu the menu is dismissed, but the margin remains. By using the parent of dropdown-menu the click event is still registered whenever a child of the parent is clicked. If a sibling is used then the trigger doesn't happen.
$("li.dropdown").click(function() {
$("nav.navbar").toggleClass("open");
});
body {
margin: 0;
padding: 0;
font-family: "Helvetica", "Arial", sans-serif;
font-weight: 500;
font-style: normal;
font-size: 12px;
line-height: 1.5;
}
.navbar-default {
background-color: #ffffff;
}
.navbar {
min-height: 65px;
padding-top: 5px;
margin-bottom: 0px;
border-bottom: solid 2px #eee;
}
.navbar-header {
margin-top: -12px;
}
.navbar-brand {
padding-top: 0px !important;
}
/* for button placement*/
.navbar-toggle {
margin-top: 26px;
}
/*for collapsed navbar*/
.navbar-collapse {
margin-top: 12px;
}
.site-logo {
max-width: 135px;
min-width: 120px;
}
.navbar-default .navbar-nav > li > a {
text-transform: uppercase;
background-color: #ffffff !important;
color: #333333;
}
.navbar-default .navbar-nav > li > a:hover {
color: #3381d0;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
background-color: #ffffff;
border-bottom: 2px solid #ff5d1c;
color: #ff5d1c;
bottom: -2px;
}
.nav>li {
position: static !important;
}
/* For navbar dropdown*/
.navbar .dropdown-menu {
min-width: 1349px;
width: 100%;
height: 120px;
margin-top: 51px;
z-index: 1;
left: 0;
text-align: center;
padding-right: 10px;
position: absolute;
list-style-type: none;
border-top: 2px solid #ff5d1c;
border-bottom: 2px solid #333333;
border-right: #ffffff;
border-radius: 0;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
border-left: 0;
background-color: #337ab7;
}
.dropdown-menu {
padding-left: 10px;
padding-right: 10px;
position: relative;
list-style-type: none;
}
.navbar .dropdown-menu li {
margin: 0;
padding: 0;
display: inline-block;
}
.dropdown-menu > li > a {
color: #ffffff;
line-height: 75px;
padding: 3px;
}
.dropdown-menu > li > a:hover {
color: #333333 !important;
}
.dropdown-menu > li > a:hover {
color: #ffffff;
background-color: #337ab7;
}
.m-pub {
display: inline-block;
margin: 3px 40px 0;
font-size: 13px;
font-weight: 400;
text-transform: uppercase;
letter-spacing: .14em;
color: white;
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
position: relative;
}
.m-pub:after,
.m-pub:focus {
color: #ffffff;
background-color: #337ab7;
}
.dropdown-menu li .m-pub:hover:after {
content: '';
position: absolute;
left: 50%;
margin-left: -10px;
margin-top: 55px;
border-left: 0;
border-bottom: 17px solid transparent;
border-top: 17px solid transparent;
border-left: 14px solid #333333;
transform: rotate(-90deg);
background: none;
}
nav.navbar.open {
margin-bottom: 120px;
}
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#"></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav" id="nav">
<li class="nav-link active">Link
</li>
<li class="nav-link">Link
</li>
<li class="nav-link">Link
</li>
<li class="dropdown">
Drop-Down Menu<i class="fa fa-angle-down flipped"></i>
<ul class="dropdown-menu" id="menu">
<li class="nav-link">
<i class="fa fa-microphone fa-2x"></i>Option
</li>
<li class="nav-link">
<i class="fa fa-newspaper-o fa-2x"></i>Option
</li>
</ul>
</li>
<li class="nav-link">Link
</li>
<li class="nav-link">Link
</li>
</ul>
</div>
</div>
</nav>
<div class="container" style="background: red;height:100px; width: 100%;">
</div>
<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.5/js/bootstrap.min.js"></script>
</body>
The snippet is small enough that it engages the mobile view, so you'll need to view it in full screen. Or you can check out the codepen.
As a note of caution, some of the stylings you have added for .dropdown-menu break the mobile version, so you may want to take a look at them, or add some media queries to fix them up a bit.
Use bootstrap accordion, it uses bootstrap css and you can use a single accordion item as a drop down to push content down, this is bootstrap code so you can just copy and depending on whether you want it closed or opened just use class="collapse" or class="show" respectively. use accordion as a dropdown wherever you want it in your navigation bar
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingOne">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
Accordion Item #1
</button>
</h2>
<div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
Accordion Item #2
</button>
</h2>
<div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item's accordion body. Let's imagine this being filled with some actual content.</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingThree">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseThree" aria-expanded="false" aria-controls="flush-collapseThree">
Accordion Item #3
</button>
</h2>
<div id="flush-collapseThree" class="accordion-collapse collapse" aria-labelledby="flush-headingThree" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the third item's accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.</div>
</div>
</div>
</div>