bootstrap 5 navbar collapse div height not working - css

I am using bootstrap5 navbar.In the navbar there is dropdown menu link.It works but the problem is that on 320*480 screen size the dropdown collapses but can't scroll or access the menu items inside the dropdown.Can anyone help me to resolve this issue.Thanks for the help in advance.My code:https://codepen.io/ANANTHUC/full/RwjvVKe
$(function () {
$(".dropdown-menu a.dropdown-toggle").on("click", function (e) {
if (!$(this).next().hasClass("show")) {
$(this).parents(".dropdown-menu").first().find(".show").removeClass("show");
}
var $subMenu = $(this).next(".dropdown-menu");
$subMenu.toggleClass("show");
$(this)
.parents("li.nav-item.dropdown.show")
.on("hidden.bs.dropdown", function (e) {
$(".dropdown-submenu .show").removeClass("show");
});
return false;
});
$(".firstLevel").on("click", function (e) {
$(this).toggleClass("dropdown-Opened");
var sublevel_Dropdown = $(".firstLevel").next("ul").find(".subLevel");
if (sublevel_Dropdown.hasClass("dropdown-Opened")) {
$(sublevel_Dropdown).removeClass("dropdown-Opened");
$(sublevel_Dropdown).next('.dropdown-menu').removeClass("show")
}
if ($(".firstLevel").not(this).hasClass("dropdown-Opened")) {
$(".firstLevel").not(this).removeClass("dropdown-Opened");
//alert("class added");
}
});
$(".subLevel").on("click", function (e) {
$(this).toggleClass("dropdown-Opened");
});
var main__nestedDropdown = $(".subLevel").parent("li").parent("ul").prev("a.subLevel");
$(main__nestedDropdown).on("click", function (e) {
var child__nestedDropdown = main__nestedDropdown.next("ul").find("a.subLevel");
// alert("class added");
if (child__nestedDropdown.hasClass("dropdown-Opened")) {
$(child__nestedDropdown).removeClass("dropdown-Opened");
}
});
});
.menu-area {
background: #563d7c;
}
.dropdown-menu {
padding: 0;
margin: 0;
border: 0 solid transition !important;
border: 0 solid rgba(0, 0, 0, 0.15);
border-radius: 0;
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
.mainmenu a,
.navbar-default .navbar-nav > li > a,
.mainmenu ul li a,
.navbar-expand-lg .navbar-nav .nav-link {
color: #fff !important;
font-size: 16px;
text-transform: capitalize;
padding: 16px 15px;
font-family: "Roboto", sans-serif;
display: block !important;
}
.mainmenu .active a,
.mainmenu .active a:focus,
.mainmenu .active a:hover,
.mainmenu li a:hover,
.mainmenu li a:focus,
.navbar-default .navbar-nav > .show > a,
.navbar-default .navbar-nav > .show > a:focus,
.navbar-default .navbar-nav > .show > a:hover {
color: #fff;
}
/*==========Sub Menu=v==========*/
#media screen and (min-width: 992px) {
.mainmenu .collapse ul > li:hover > a {
background: #d61a5e;
}
.mainmenu .collapse ul ul > li:hover > a,
.navbar-default .navbar-nav .show .dropdown-menu > li > a:focus,
.navbar-default .navbar-nav .show .dropdown-menu > li > a:hover {
background: #d61a5e;
}
.mainmenu .collapse ul ul ul > li:hover > a {
background: #4caf50;
}
}
.mainmenu .collapse ul ul,
.mainmenu .collapse ul ul.dropdown-menu {
background: #1565c0;
}
.mainmenu .collapse ul ul ul,
.mainmenu .collapse ul ul ul.dropdown-menu {
background: #1e88e5;
}
.mainmenu .collapse ul ul ul ul,
.mainmenu .collapse ul ul ul ul.dropdown-menu {
background: #64b5f6;
}
/******************************Drop-down menu work on hover**********************************/
.mainmenu {
background: none;
border: 0 solid;
margin: 0;
padding: 0;
min-height: 20px;
width: 100%;
}
#media only screen and (min-width: 992px) {
.mainmenu .collapse ul li:hover > ul {
display: block;
}
.mainmenu .collapse ul ul {
position: absolute;
top: 100%;
left: 0;
min-width: 250px;
display: none;
}
/*******/
.mainmenu .collapse ul ul li {
position: relative;
}
.mainmenu .collapse ul ul li:hover > ul {
display: block;
}
.mainmenu .collapse ul ul ul {
position: absolute;
top: 0;
left: 100%;
min-width: 250px;
display: none;
}
/*******/
.mainmenu .collapse ul ul ul li {
position: relative;
}
.mainmenu .collapse ul ul ul li:hover ul {
display: block;
}
.mainmenu .collapse ul ul ul ul {
position: absolute;
top: 0;
left: -100%;
min-width: 250px;
display: none;
z-index: 1;
}
}
#media only screen and (max-width: 991px) {
.navbar-nav .show .dropdown-menu .dropdown-menu > li > a {
padding: 16px 15px 16px 35px;
}
.navbar-nav .show .dropdown-menu .dropdown-menu .dropdown-menu > li > a {
padding: 16px 15px 16px 45px;
}
.navbar-nav .dropdown .dropdown-toggle::after {
content: "+" !important;
font-size: 20px;
vertical-align: 0;
top: 8px;
border: 1px solid #fff;
right: 40px;
width: 32px;
height: 32px;
text-align: center;
position: absolute;
}
.navbar-nav .dropdown .dropdown-Opened::after {
content: "-" !important;
}
div#navbarSupportedContent {
position: absolute;
width: 100%;
z-index: 1;
top: 56px;
left: 0;
background: #0062cc;
}
/*Slide from left
.navbar-collapse {
position: fixed;
top: 56px;
left: 0;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 15px;
width: 75%;
background-color: #1e88e5;
height: 100%;
}
.navbar-collapse.collapsing {
left: -75%;
transition: height 0s ease;
}
.navbar-collapse.show {
left: 0;
transition: left 300ms ease-in-out;
}
.navbar-toggler.collapsed ~ .navbar-collapse {
transition: left 500ms ease-in-out;
}
*/
}
header {
position: fixed;
width: 100%;
z-index: 2;
}
#banner {
background: url("../img/banner.png") no-repeat;
background-size: cover;
height: 600px;
}
#banner h1 {
color: #fff;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js"></script>
<header id="menu_area" class="menu-area">
<div class="container">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-expand-lg navbar-light mainmenu">
<div class="container-fluid">
<div class="logo">
<a class="navbar-brand" href="index.html">
LOGO
</a>
</div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-lg-auto customNav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle firstLevel" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Main Dropdown
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li class="dropdown">
<a class="dropdown-toggle subLevel" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sub Dropdown1</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="dropdown">
<a class="dropdown-toggle subLevel" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Sub Dropdown2</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Service</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle firstLevel " href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Main Dropdown2
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</div>
</header>
<main>
<section id="banner">
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-12">
<h1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae sit dignissimos totam dolore corporis! </h1>
</div>
</div>
</section>
</main>

Update following style in css.
div#navbarSupportedContent {
position: absolute;
width: 100%;
z-index: 1;
top: 56px;
left: 0;
background: #0062cc;
overflow: hidden;
overflow-y: auto;
max-height: calc(100vh - 56px);
}

In bootstrap 5 there is a CSS class navbar-nav-scroll to handle the scroll behaviour. Try this in your code:
<ul class="navbar-nav ms-lg-auto customNav navbar-nav-scroll">
also, you can adjust the scroll length by using style="--bs-scroll-height: 100px;", so it will be like this
<ul class="navbar-nav ms-lg-auto customNav navbar-nav-scroll" style="--bs-scroll-height: 100px;">
reference at bootstrap doc

Related

How to prevent Dropdown toggle button from changing it's own width

.nav {
/ / display: flex;
width: 100%;
}
.navbar-default .navbar-nav > li > a:focus, .navbar-default .navbar-nav > li > a:hover {
color: #333;
background-color: transparent;
}
.nav > li {
display: inline-block !important;
}
.number_three_li {
float: right;
}
#media (min-width: 768px) {
.navbar-nav > li.number_three_li {
float: right;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top" style="background-color: transparent; max-height: 50px;">
<div class="container-fluid" style="padding-right: 0px;">
<ul class="nav navbar-nav" style="margin-top: 0px;margin-bottom: 0px;padding-left: 0px;">
<li class="number_three_li dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"
style="padding: 15px"><i
class="glyphicon glyphicon-option-horizontal" style="color:royalblue;"></i></a>
<ul class="dropdown-menu" style="z-index: 3; left: auto; right: 0;">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
</ul>
</div>
</nav>
<p style="padding-top:100px">It happend when browser's width < 768</p>
When I click button of dropdown, it's button width changes.
Before:
After click:
But what I want is that: The button is never changes, clicked button effect also removed, but just dropdown menu opens only.
Like this:
How to fix it?
use:
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:focus, .navbar-default .navbar-nav>.open>a:hover {
background-color: transparent!important;
}
.nav > li a.dropdown-toggle {
text-align: right;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:focus, .navbar-default .navbar-nav>.open>a:hover {
background-color: transparent!important;
}
.nav > li a.dropdown-toggle {
text-align: right;
}
.nav {
/ / display: flex;
width: 100%;
}
.navbar-default .navbar-nav > li > a:focus, .navbar-default .navbar-nav > li > a:hover {
color: #333;
background-color: transparent;
}
.nav > li {
display: inline-block !important;
}
.number_three_li {
float: right;
}
#media (min-width: 768px) {
.navbar-nav > li.number_three_li {
float: right;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top" style="background-color: transparent; max-height: 50px;">
<div class="container-fluid" style="padding-right: 0px;">
<ul class="nav navbar-nav" style="margin-top: 0px;margin-bottom: 0px;padding-left: 0px;">
<li class="number_three_li dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"
style="padding: 15px"><i
class="glyphicon glyphicon-option-horizontal" style="color:royalblue;"></i></a>
<ul class="dropdown-menu" style="z-index: 3; left: auto; right: 0;">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
</ul>
</div>
</nav>
<p style="padding-top:100px">It happend when browser's width < 768</p>
Problem with Indentation
Can you just add a text-align:right;
.nav > li a.dropdown-toggle {
text-align: right;
}
Problem with Background-color
Add this css to keep the background transparent when it opens
.navbar-default .nav.navbar-nav>.open>a,
.navbar-default .nav.navbar-nav>.open>a:focus,
.navbar-default .nav.navbar-nav>.open>a:hover {
color: #555;
background-color: transparent;
}
Code Snippet
.nav {
// display: flex;
width: 100%;
}
.navbar-default .navbar-nav > li > a:focus, .navbar-default .navbar-nav > li > a:hover {
color: #333;
background-color: transparent;
}
.nav > li {
display: inline-block !important;
}
.nav > li a.dropdown-toggle {
text-align: right;
}
.navbar-default .nav.navbar-nav>.open>a, .navbar-default .nav.navbar-nav>.open>a:focus, .navbar-default .nav.navbar-nav>.open>a:hover {
color: #555;
background-color: transparent;
}
.number_three_li {
float: right;
}
#media (min-width: 768px) {
.navbar-nav > li.number_three_li {
float: right;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top" style="background-color: transparent; max-height: 50px;">
<div class="container-fluid" style="padding-right: 0px;">
<ul class="nav navbar-nav" style="margin-top: 0px;margin-bottom: 0px;padding-left: 0px;">
<li class="number_three_li dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"
style="padding: 15px"><i
class="glyphicon glyphicon-option-horizontal" style="color:royalblue;"></i></a>
<ul class="dropdown-menu" style="z-index: 3; left: auto; right: 0;">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
</ul>
</div>
</nav>
<p style="padding-top:100px">It happend when browser's width < 768</p>

Top Align ULs When Parent Text Wraps

I have a nav that when a parent text wraps, it drops the UL down so it does not top align with adjacent ULs.
In the fiddle below, I would like Find a Park to be top aligned with the adjacent Golf Preserve and Recreation Center LIs , where currently it is not top aligned with the adjacent LIs.
https://jsfiddle.net/vge8vuxd/
<div class="row TopNavMain">
<ul class="nav mobile-nav">
<li class="active level0">
<a class="has-sub-menu active" href="http://www.someurl.com/PlayRecreation"><span>Play & Recreation</span><span class="border"></span></a><i class="fa fa-chevron-down"></i>
<ul class="sub-menu">
<li class="level1">
<a class="has-sub-menu " href="http://www.someurl.com/PlayRecreation/GolfHere"><span>Golf Here</span><span class="border"></span></a><i class="fa fa-chevron-down"></i>
<ul class="sub-menu">
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/GolfHere/GolfPreserve"><span> Golf Preserve</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/GolfHere/GolfCourse"><span> Golf Course</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/GolfHere/BookTeeTimes"><span>Book Tee Times</span><span class="border"></span></a></li>
</ul>
</li>
<li class="level1">
<a class="has-sub-menu " href="http://www.someurl.com/PlayRecreation/Popcorn,TrailsOpenSpace"><span>Popcorn, Trails & Open Space</span><span class="border"></span></a><i class="fa fa-chevron-down"></i>
<ul class="sub-menu">
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/Play,TrailsOpenSpace/FindaPark"><span>Find a Park</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/Play,TrailsOpenSpace/OpenSpaceTrails"><span>Open Space & Trails</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/Play,TrailsOpenSpace/Forestry"><span>Forestry</span><span class="border"></span></a></li>
</ul>
</li>
<li class="level1">
<a class="has-sub-menu " href="http://www.someurl.com/PlayRecreation/RecreationCenters"><span>Recreation Centers</span><span class="border"></span></a><i class="fa fa-chevron-down"></i>
<ul class="sub-menu">
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/RecreationCenters/RecreationCenter"><span> Recreation Center</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/RecreationCenters/FitnessCenter"><span> Fitness Center</span><span class="border"></span></a></li>
<li class="level2"><a class="" href="http://www.someurl.com/PlayRecreation/RecreationCenters/AnotherFitnessCenter"><span> Another Fitness Center</span><span class="border"></span></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
.TopNavMain ul,
.TopNavMain ul li {
display: block;
margin: 0px;
padding: 0px;
list-style-type: none;
position: unset;
}
.TopNavMain ul.nav li a {
display: block;
background: none;
}
.TopNavMain ul.nav li a span {
display: block;
}
.TopNavMain ul.nav > li > a {
position: static;
padding: 17px 20px;
color: #555759;
font-size: 16px;
line-height: 100%;
letter-spacing: 1px;
}
.TopNavMain ul.nav {
display: table;
width: 95%;
float: right;
}
.TopNavMain ul.nav > li {
display: table-cell;
}
.TopNavMain ul.nav > li > a {
text-align: center;
position: relative;
}
.TopNavMain ul.nav li .sub-menu {
display: table;
position: relative;
width: auto !important;
text-align: left;
}
.TopNavMain ul.nav li .sub-menu li {
display: table-cell;
padding: 20px 10px 35px;
vertical-align: top;
}
.TopNavMain ul.nav li .sub-menu a {
display: inline-block;
margin: 10px 0 20px;
padding: 5px 0px;
color: #555759;
font-size: 16px;
line-height: 100%;
font-weight: bold;
}
.TopNavMain ul.nav li .sub-menu ul li {
width: 100% !important;
display: block;
float: left;
text-align: left;
padding: 0;
margin: 10px 0 0;
}
.TopNavMain ul.nav li .sub-menu ul a {
padding: 5px 0;
font-size: 13px;
color: #797b7c;
font-weight: normal;
}
.TopNavMain ul.nav li .sub-menu li ul li a {
margin: 0;
}
.TopNavMain ul.nav li .sub-menu ul li ul {
display: none;
}
Thanks for any assistance.
You need to put a fixed height on
.TopNavMain ul.nav li .sub-menu a {
....
height:20px;
}

CSS - best way for a drop-menu menu to have the same width as the parent

What is the best way for a drop-menu menu has the same width as the parent. Please HTML and CSS from below. Please also see https://jsfiddle.net/rd8Lq7dn/. I'm trying to find a solution that I don't need the specific the actual pixels in the width.
body {
background-color: #eee;
padding: 0;
}
.inline-menu,
.inline-menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li {
display: inline-block;
padding-right: 25px;
background-color: yellow;
position: relative;
}
.inline-menu a {
text-decoration: none;
}
.inline-menu > li > ul {
display: none;
position: absolute;
background-color: green;
}
.inline-menu > li:hover > ul {
display: block;
}
<nav>
<span class="logo"></span>
<ul class="inline-menu left-menu">
<li>L-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>L-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
</nav>
Just give 100% width to the child.it will inherit the width of its parent.
.inline-menu > li:hover > ul{
display: block;
width: 100%;
}
body {
background-color: #eee;
padding: 0;
}
.inline-menu,
.inline-menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li {
display: inline-block;
padding-right: 25px;
background-color: yellow;
position: relative;
}
.inline-menu a {
text-decoration: none;
}
.inline-menu > li > ul {
display: none;
position: absolute;
background-color: green;
}
.inline-menu > li:hover > ul {
display: block;
width: 100%;
}
<nav>
<span class="logo"></span>
<ul class="inline-menu left-menu">
<li>L-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>L-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
</nav>

remove responsiveness to nav bar

I used <div id="mws-nav-collapse"> for responsiveness; it worked.
Now I don't need responsiveness, so when I delete this div, I didn't view my nav-bar items in mobile view. How do I make my nav-bar items visible in the mobile view without using responsiveness.
Here is my code:
<div id="mws-navigation">
<ul id="link">
<li data-related="c" class="" id="c1"><i class="icon-calendar"></i>AAA</li>
<li data-related="e" class="" id="e1"><i class="icon-tag"></i>BBB</li>
<li data-related="f" class="" id="f1"><i class="icon-hdd"></i>CCC</li>
</ul>
</div>
the div which i removed
<div id="mws-nav-collapse">
<span></span>
<span></span>
<span></span>
</div>
It is available in bootstrap docs
What changes
Note the lack of the <meta name="viewport" content="width=device-width, initial-scale=1">, which disables the zooming aspect of sites in mobile devices. In addition, we reset our container's width and are basically good to go.
Regarding navbars
As a heads up, the navbar component is rather tricky here in that the styles for displaying it are rather specific and detailed. Overrides to ensure desktop styles display are not as performant or sleek as one would like. Just be aware there may be potential gotchas as you build on top of this example when using the navbar.
Browsers, scrolling, and fixed elements
Non-responsive layouts highlight a key drawback to fixed elements. Any fixed component, such as a fixed navbar, will not be scrollable when the viewport becomes narrower than the page content. In other words, given the non-responsive container width of 970px and a viewport of 800px, you'll potentially hide 170px of content.
There is no way around this as it's default browser behavior. The only solution is a responsive layout or using a non-fixed element.
Example code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Non-responsive Template for Bootstrap</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="non-responsive.css" rel="stylesheet">
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#">Project name</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
The text
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
non-responsive.css
body {
padding-top: 70px;
padding-bottom: 30px;
}
body,
.navbar-fixed-top,
.navbar-fixed-bottom {
min-width: 970px;
}
.lead {
font-size: 16px;
}
.page-header {
margin-bottom: 30px;
}
.page-header .lead {
margin-bottom: 10px;
}
.container {
width: 970px;
max-width: none !important;
}
.col-xs-4 {
padding-top: 15px;
padding-bottom: 15px;
background-color: #eee;
background-color: rgba(86,61,124,.15);
border: 1px solid #ddd;
border: 1px solid rgba(86,61,124,.2);
}
.container .navbar-header,
.container .navbar-collapse {
margin-right: 0;
margin-left: 0;
}
.navbar-header {
float: left;
}
.navbar-collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
visibility: visible !important;
}
.navbar-toggle {
display: none;
}
.navbar-collapse {
border-top: 0;
}
.navbar-brand {
margin-left: -15px;
}
.navbar-nav {
float: left;
margin: 0;
}
.navbar-nav > li {
float: left;
}
.navbar-nav > li > a {
padding: 15px;
}
.navbar-nav.navbar-right {
float: right;
}
.navbar .navbar-nav .open .dropdown-menu {
position: absolute;
float: left;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, .15);
border-width: 0 1px 1px;
border-radius: 0 0 4px 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: #333;
}
.navbar .navbar-nav .open .dropdown-menu > li > a:hover,
.navbar .navbar-nav .open .dropdown-menu > li > a:focus,
.navbar .navbar-nav .open .dropdown-menu > .active > a,
.navbar .navbar-nav .open .dropdown-menu > .active > a:hover,
.navbar .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #fff !important;
background-color: #428bca !important;
}
.navbar .navbar-nav .open .dropdown-menu > .disabled > a,
.navbar .navbar-nav .open .dropdown-menu > .disabled > a:hover,
.navbar .navbar-nav .open .dropdown-menu > .disabled > a:focus {
color: #999 !important;
background-color: transparent !important;
}
.navbar-form {
float: left;
width: auto;
padding-top: 0;
padding-bottom: 0;
margin-right: 0;
margin-left: 0;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-form .form-group {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
}
.navbar-form .form-control {
display: inline-block;
width: auto;
vertical-align: middle;
}
.navbar-form .form-control-static {
display: inline-block;
}
.navbar-form .input-group {
display: inline-table;
vertical-align: middle;
}
.navbar-form .input-group .input-group-addon,
.navbar-form .input-group .input-group-btn,
.navbar-form .input-group .form-control {
width: auto;
}
.navbar-form .input-group > .form-control {
width: 100%;
}
.navbar-form .control-label {
margin-bottom: 0;
vertical-align: middle;
}
.navbar-form .radio,
.navbar-form .checkbox {
display: inline-block;
margin-top: 0;
margin-bottom: 0;
vertical-align: middle;
}
.navbar-form .radio label,
.navbar-form .checkbox label {
padding-left: 0;
}
.navbar-form .radio input[type="radio"],
.navbar-form .checkbox input[type="checkbox"] {
position: relative;
margin-left: 0;
}
.navbar-form .has-feedback .form-control-feedback {
top: 0;
}
You can find this in examples

CSS dropdown menu,the submenu showed on hover dissapears while you browse submenu

Hello I have CSS dropdown menu, when I hover with the mouse to the firt item the submenu shows correctly but when I try to go down for example to the last item of the submenu before I get there the submenu gets closed... I can't find what I'm doing wrong Below is my code:
CSS:
#lang_select ul{
padding: 0px;
margin: 0;
border: solid 1px #e1e1e1;
width: 85px;
}
#lang_select li{
display: inline;
position: relative;
}
#lang_select ul ul{
position: absolute;
display: none;
}
#lang_select li:hover ul{
display: block;
}
#lang_select a{
text-decoration: none;
color:#333;
font-family: Open Sans;
font-size:12px;
}
.lang-down{
padding-left:10px;
}
HTML:
<div id="lang_select">
<ul>
<li>
  Language  <i class="fa fa-angle-down"></i>
<ul>
<li><span class="lang-down"><i class="fa fa-globe"></i> Albanian</span></li>
<li><span class="lang-down"><i class="fa fa-globe"></i> French</span></li>
<li><span class="lang-down"><i class="fa fa-globe"></i> German</span></li>
</ul>
</li>
</ul>
</div>
demo - http://jsfiddle.net/r0bdcn7y/1/
change the css
#lang_select li {
display: inline-block;
position: relative;
width: 100%;
}
#lang_select ul {
padding: 0px;
margin: 0;
border: solid 1px #e1e1e1;
width: 85px;
}
#lang_select li {
display: inline-block;
position: relative;
width: 100%;
}
#lang_select ul ul {
position: absolute;
display: none;
}
#lang_select li:hover ul {
display: block;
}
#lang_select a {
text-decoration: none;
color: #333;
font-family: Open Sans;
font-size: 12px;
}
.lang-down {
padding-left: 10px;
}
<div id="lang_select">
<ul>
<li> Language <i class="fa fa-angle-down"></i>
<ul>
<li><span class="lang-down"><i class="fa fa-globe"></i> Albanian</span>
</li>
<li><span class="lang-down"><i class="fa fa-globe"></i> French</span>
</li>
<li><span class="lang-down"><i class="fa fa-globe"></i> German</span>
</li>
</ul>
</li>
</ul>
</div>

Resources