I have a search box placed inside a bunch of <li> tags in my Bootstrap Navbar. It works fine in regular mode; however, when collapsed, it disappears upon touch, along with the rest of the drop-down. Here's the HTML markup:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<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>
<a class="navbar-brand" href="#"><img src="bootstrap/img/gray_logo.png" class="site-logo"><span class="site-name-first">Always</span><span class="site-name-second">Spanish</span></a>
</div>
<!-- Navbar links -->
<div class="collapse navbar-collapse" ng-controller="HeaderController">
<ul class="nav navbar-nav navbar-right">
<li ng-class="{ active: isActive('/about')}">About</li>
<li ng-class="{ active: isActive('/blog')}">Blog</li>
<li>Premium</li>
<li>Books</li>
<li>Contact</li>
<li>
<!-- Search box -->
<form class="navbar-form pull-right search-box" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</li>
</ul>
</div>
</div>
</div>
I understand this is by design as the drop down must disappear once an item is tapped. But this functionality also means one wouldn't be able to use the search box in the collapsed mode. Is there any (preferably pure CSS) workaround? Here's the drop down I am talking about:
This is what the navbar looks like on a regular desktop viewport:
Here's the complete CSS:
* {
border-radius: 0 !important;
}
#media (max-width: 760px) {
h1 {
font-size: 210%;
}
.jumbotron p {
font-size: 120%;
}
}
.navbar-text > a {
color: inherit;
text-decoration: none;
}
body {
padding-top: 50px;
}
.row-padding {
padding-left: 20px;
padding-right: 20px;
padding-bottom: 50px;
}
p {
font-family: 'Open Sans', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Oswald', sans-serif;
}
.site-name-first {
padding-left: 10px;
font-family: 'Caesar Dressing', cursive;
font-size: 1.5em;
color: #6495ed;
}
.site-name-second {
font-family: 'Caesar Dressing', cursive;
font-size: 1.5em;
color: #ff6666;
}
.site-logo {
float:left;
margin-top: -8px;
width: 36px;
}
/* CSS to change Navbar collapse threshold [START]
===================================================================*/
#media (max-width: 991px) {
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-text {
float: none;
margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
display: block!important;
}
.collapsing {
overflow: hidden!important;
}
}
/* CSS to change Navbar collapse threshold [END]
===================================================================*/
#media (min-width: 761px) {
.navbar-default {
background-color: rgba(255, 255, 255, 0.9);
border-bottom: 0px;
color: #666666;
margin: 0px;
}
}
#media (max-width: 760px) {
.navbar-default {
background-color: rgba(255, 255, 255, 1);
border-bottom: 0px;
color: #666666;
margin: 0px;
}
}
/*.search-box {
margin-right: -15px;
}*/
.navbar-static-bottom {
background-color: #ffcc00;
border: none;
color: #665100;
margin-bottom: 0px;
padding-top: 0px;
}
.navbar-static-bottom .socials {
color: #665100;
}
.footer-text {
padding-top: 17px;
}
.footer-text a {
color: #665100;
}
.navbar-default .navbar-nav > li > a,
.navbar-default .navbar-nav > li > a:focus {
outline: none;
color: #70704c;
font-weight: 700;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
background-color: #ffffff;
box-shadow: inset 0 -5px 0 0 #665100;
}
.navbar-default .navbar-nav > li > a:hover {
background-color: #ffffff;
box-shadow: inset 0 -5px 0 0 #cca300;
color: #cca300;
transition: color 0.15s ease;
}
/* when a dropdown menu item is clicked open */
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
background-color: #ffffff;
box-shadow: inset 0 -5px 0 0 #cca300;
}
.home-thumb img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
}
.thumbnail img {
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
width: 100%;
}
.thumbnail {
overflow: hidden;
}
.bg-gray {
background-color: #f9f9f9;
}
.facebook-color:hover { color: #3b5998; }
.twitter-color:hover { color: #4099ff; }
.googleplus-color:hover { color: #d50f25; }
.youtube-color:hover { color: #c4302b; }
.pinterest-color:hover { color: #c92228; }
.top-jumbotron {
background: #ffcc00;
height: 500px;
margin: 0px;
border: none;
}
.second-jumbotron {
margin: 0px;
background: #332800;
color: #ffcc00;
font-size: 500%;
line-height: 50%;
padding-top: 0.3em;
padding-bottom: 0.6em;
font-family: 'Mr Dafoe', cursive;
}
.contact-box {
border-color: #ffcc00;
}
.contact-title {
text-align: center;
background-color: #ffcc00;
border-color: #ffcc00;
}
.contact-title h4 {
font-size: 220%;
color: #545454;
}
.contact-body {
background-color: #ffea99;
border-color: #ffea99;
color: #545454;
}
.contact-footer {
background-color: #ffcc00;
border-color: #ffcc00;
}
.contact-field {
background-color: #fff9e5;
box-shadow: #b2b2b2 0px 0px 8px;
}
.contact-field:hover,
.contact-field:focus {
background-color: #fff;
box-shadow: #b2b2b2 0px 0px 03px inset;
}
.contact-field-single {
height: 3em;
}
.contact-send {
background-color: #4c3d00;
border-color: #4c3d00;
color: #ffffff;
width: 7em;
}
.contact-send:hover,
.contact-send:focus,
.contact-send:active {
background-color: #2d2400;
border-color: #2d2400;
color: #ffffff;
}
.contact-close {
background-color: #938a66;
border-color: #938a66;
color: #ffffff;
width: 7em;
}
.contact-close:hover,
.contact-close:focus,
.contact-close:active {
background-color: #81774c;
border-color: #81774c;
color: #ffffff;
}
.airmail {
width: 50px;
float: left;
padding: 0px;
}
.pre-footer-jumbotron {
background-color: #ffefb2;
height: 50px;
margin-bottom: 0px;
}
As far as I'm concerned the easiest solution is to remove the form from li and add it separately as described in bootstrap documentation.
<ul class="nav navbar-nav navbar-right">
<li ng-class="{ active: isActive('/about')}">About</li>
<li ng-class="{ active: isActive('/blog')}">Blog</li>
<li>Premium</li>
<li>Books</li>
<li>Contact</li>
</ul>
<form class="navbar-form pull-right search-box" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
bootstrap documentation
Related
When hovering dropdown items in the hamburger menu, their contents are shown like this:
I'd like to disable this behavior on hover, so they are only shown when the dropdown is clicked.
Tried this, no luck.
#media only screen and (min-width: 768px) {
li.dropdown:hover > ul {
display: none;
}
}
.navbar {
border: none;
}
.dropdown-menu {
background-color: #f5f5f5;
}
.navbar-header {
background-color: #3a7dbb;
}
.collapse.navbar-collapse.js-navbar-collapse {
background-color: #3a7dbb;
}
.navbar-default .navbar-nav > li > a.dropdown-toggle {
font-family: "Oswald",Helvetica,Arial,sans-serif;
font-size: 18px;
color: white;
}
.dropdown > .dropdown-menu > li > a {
font-size: 16px;
}
.glyphicon-shopping-cart:before {
color: white;
}
.navbar .navbar-brand {
padding-top: 0px;
}
.navbar .navbar-brand > img{
height: 100%;
}
.dropdown > .dropdown-menu > li > a:hover {
background-color: white;
}
.navbar-nav > li > .dropdown-menu {
background-color: #f5f5f5;
margin-top: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.navbar-default .navbar-nav > li > a {
/* width: 8em; */
font-weight: bold;
}
.mega-dropdown {
position: static !important;
width: 100%;
}
.mega-dropdown-menu {
padding: 20px 0px;
width: 100%;
box-shadow: none;
-webkit-box-shadow: none;
}
.center {
margin: auto;
}
.mega-dropdown-menu > li > ul {
padding: 0;
margin: 0;
}
.mega-dropdown-menu > li > ul > li {
list-style: none;
}
.mega-dropdown-menu > li > ul > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #262626;
white-space: normal;
}
.mega-dropdown-menu > li ul > li > a {
font-size: 16px;
}
.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
text-decoration: none;
color: #444;
background-color: white;
}
li.dropdown:hover {
background-color: #c3c1c1;
}
ul.dropdown-menu.mega-dropdown-menu.row {
width: 80%;
left: 0;
right: 0;
margin: 0 auto; /* Centers the element */
}
.mega-dropdown-menu .dropdown-header {
color: #428bca;
font-size: 18px;
font-weight: bold;
}
.mega-dropdown-menu .dropdown-header > a {
color: #428bca;
font-size: 18px;
font-weight: bold;
padding-left: 0;
}
.mega-dropdown-menu form {
margin: 3px 20px;
}
.mega-dropdown-menu .form-group {
margin-bottom: 3px;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: black !important;
}
/* .mega-dropdown-menu:before {
content: "";
border-bottom: 15px solid #fff;
border-right: 17px solid transparent;
border-left: 17px solid transparent;
position: absolute;
top: -15px;
left: 285px;
z-index: 10;
}
.mega-dropdown-menu:after {
content: "";
border-bottom: 17px solid #ccc;
border-right: 19px solid transparent;
border-left: 19px solid transparent;
position: absolute;
top: -17px;
left: 283px;
z-index: 8;
} */
.dropdown:hover .dropdown-menu {
display: block;
margin-top: 0; // remove the gap so it doesnt close
}
#main_pnlSiteTemplateHeader {
background-color: white;
padding-left: 0px;
padding-right: 0px;
}
#main_content_Content {
padding-top: 80px;
}
#main_content_TopBanner {
padding-top: 80px;
}
ul.dropdown-menu.mega-dropdown-menu.row {
top: 49px;
}
#media only screen and (min-width: 768px) {
.dropdown:hover > .dropdown-menu {
display: block;
}
.dropdown > .dropdown-toggle:active {
pointer-events: none;
}
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald|Open+Sans:400,400italic,600italic,600">
<!------ Include the above in your HEAD tag ---------->
<div class="">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-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 js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
About<span class="caret"></span>
<ul class="dropdown-menu mega-dropdown-menu row">
<li class="col-sm-4">
<ul>
<li class="dropdown-header">Business Relationship Management</li>
<li>Capability</li>
<li>Role</li>
</ul>
</li>
<li class="col-sm-4">
</li>
<li class="col-sm-4">
</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
please try below css:
<style>
.dropdown:hover > .dropdown-menu {
display: none;
}
.navbar-default .navbar-nav > li > a:focus + ul.dropdown-menu {
display: block;
top: auto;
width: 100%;
margin-top: 7px;
}
</style>
I have this code (this is bootstrap fixed navbar menu):
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid container_mop">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#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>
</div>
<a class="navbar-brand" href="#"><img src="images/logo.png" class="center img-responsive logo_top"></a>
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav navbar-left navbar_odstep">
<li class="mopy_menu_1">O mnie</li>
<li class=" mopy_menu_1 dropdown ">
gabinet <span class="caret"></span>
<ul class="dropdown-menu dropdownPadding">
<li class=" mopy_menu_dropdown">- Gdzie przyjmuje </li>
<li class=" mopy_menu_dropdown">- Badania </li>
<li class=" mopy_menu_dropdown">- Zabiegi</li>
<li class=" mopy_menu_dropdown">- Przygotowanie </li>
</ul>
</li>
<li class="mopy_menu_1">Usługi</li>
<li class="mopy_menu_1">Cennik</li>
<li class="mopy_menu_1">Artykuły</li>
</ul>
<ul class="nav navbar-nav navbar-right navbar_odstep">
<li class="mopy_menu_1">Kontakt</li>
</ul>
</div>
</div>
</nav>
.navbar_odstep {
padding-top: 50px;
padding-bottom: 40px;
}
/*menu top*/
.navbar-default .navbar-nav > li > a {
color: white;
}
.navbar-default .navbar-nav > li > a:hover {
color: white;
}
.navbar-default .navbar-nav > li > a:focus {
color: white;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:focus,
.navbar-default .navbar-nav > .open > a:hover {
background-color: transparent !important;
color: white !important;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a:focus,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover {
background-color: #4B617F !important;
color: white !important;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
background-color: #4B617F !important;
color: white !important;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #3C4052;
}
.dropdown-menu {
background-color: #4B617F !important;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #3C4052;
}
.navbar-default {
background-color: #3C4052;
border-color: #3C4052;
}
.dropdownSelector {
padding-top: 0px !important;
position: relative;
top: -4px;
text-align: center;
}
.navbar_cor_1 {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=1);
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;
}
.mopy_menu_1 {
text-transform: uppercase;
font-size: 16px;
font-weight: normal;
}
.mopy_menu_dropdown {
text-transform: none;
font-size: 16px;
font-weight: lighter;
}
.dropdownPadding {
padding-top: 20px;
padding-bottom: 20px;
}
#media screen and (min-width: 1800px) {
.container_mop{
width: 1750px;
background-color: black;
}
.dropdown-menu:before {
position: absolute;
top: -17px;
left: 10%;
display: inline-block;
border-right: 27px solid transparent;
border-bottom: 17px solid #ccc;
border-left: 27px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu:after {
position: absolute;
top: -16px;
left: 10%;
display: inline-block;
border-right: 26px solid transparent;
border-bottom: 16px solid #4B617F;
border-left: 26px solid transparent;
content: '';
}
}
#media(min-width: 1700px) and (max-width: 1799px) {
.container_mop{
width: 1700px;
background-color: red;
}
}
#media(max-width: 480px) {
.odstepNadMenuFront {
background-color: red;
height: 120px;
}
.logo_top {
padding-top: 50px;
width: 90%;
}
.navbar_odstep {
padding-top: 50px;
padding-bottom: 0px;
}
.navbar_odstep{
padding:0 ;
}
}
When I have 480px width I have problem with scroll in menu (after click "gabinet" in menu - after open submenu). In desktop resolution I haven't any problems.
Screen with my problem:
https://imgur.com/a/bRJrIWh
Does anyone know how to fix it? The site uses Bootstrap 3
max-height is specified in bootstrap so you need to overwrite it by adding below css
.navbar-fixed-bottom .navbar-collapse, .navbar-fixed-top .navbar-collapse {
max-height: 100% !important;
}
LIVE SNIPPET
.navbar_odstep {
padding-top: 50px;
padding-bottom: 40px;
}
/*menu top*/
.navbar-default .navbar-nav > li > a {
color: white;
}
.navbar-default .navbar-nav > li > a:hover {
color: white;
}
.navbar-default .navbar-nav > li > a:focus {
color: white;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:focus,
.navbar-default .navbar-nav > .open > a:hover {
background-color: transparent !important;
color: white !important;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a:focus,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover {
background-color: #4B617F !important;
color: white !important;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
background-color: #4B617F !important;
color: white !important;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #3C4052;
}
.dropdown-menu {
background-color: #4B617F !important;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #3C4052;
}
.navbar-default {
background-color: #3C4052;
border-color: #3C4052;
}
.dropdownSelector {
padding-top: 0px !important;
position: relative;
top: -4px;
text-align: center;
}
.navbar_cor_1 {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=1);
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;
}
.mopy_menu_1 {
text-transform: uppercase;
font-size: 16px;
font-weight: normal;
}
.mopy_menu_dropdown {
text-transform: none;
font-size: 16px;
font-weight: lighter;
}
.dropdownPadding {
padding-top: 20px;
padding-bottom: 20px;
}
.navbar-fixed-bottom .navbar-collapse, .navbar-fixed-top .navbar-collapse {
max-height: 100% !important;
}
#media screen and (min-width: 1800px) {
.container_mop{
width: 1750px;
background-color: black;
}
.dropdown-menu:before {
position: absolute;
top: -17px;
left: 10%;
display: inline-block;
border-right: 27px solid transparent;
border-bottom: 17px solid #ccc;
border-left: 27px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu:after {
position: absolute;
top: -16px;
left: 10%;
display: inline-block;
border-right: 26px solid transparent;
border-bottom: 16px solid #4B617F;
border-left: 26px solid transparent;
content: '';
}
}
#media(min-width: 1700px) and (max-width: 1799px) {
.container_mop{
width: 1700px;
background-color: red;
}
}
#media(max-width: 480px) {
.odstepNadMenuFront {
background-color: red;
height: 120px;
}
.logo_top {
padding-top: 50px;
width: 90%;
}
.navbar_odstep {
padding-top: 50px;
padding-bottom: 0px;
}
.navbar_odstep{
padding:0 ;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid container_mop">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#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>
</div>
<a class="navbar-brand" href="#"><img src="images/logo.png" class="center img-responsive logo_top"></a>
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav navbar-left navbar_odstep">
<li class="mopy_menu_1">O mnie</li>
<li class=" mopy_menu_1 dropdown ">
gabinet <span class="caret"></span>
<ul class="dropdown-menu dropdownPadding">
<li class=" mopy_menu_dropdown">- Gdzie przyjmuje </li>
<li class=" mopy_menu_dropdown">- Badania </li>
<li class=" mopy_menu_dropdown">- Zabiegi</li>
<li class=" mopy_menu_dropdown">- Przygotowanie </li>
</ul>
</li>
<li class="mopy_menu_1">Usługi</li>
<li class="mopy_menu_1">Cennik</li>
<li class="mopy_menu_1">Artykuły</li>
</ul>
<ul class="nav navbar-nav navbar-right navbar_odstep">
<li class="mopy_menu_1">Kontakt</li>
</ul>
</div>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
I have a bootstrap nav fixed top with height of 120px, the nav itself looks as I want. but when it goes mobile size the links are the same height as the nav bar. I cannot figure out what I am missing..
.navbar {
background-color: rgba(0, 0, 0, .6);
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, .1);
min-height:120px !important;
}
.navbar-nav > ul, li {
padding: 0px 15px;
}
.contain-pull{
max-width: 93%;
margin: 0 auto 0 auto;
}
.navbar-nav > li > a, .navbar-brand {
padding-top:50px !important;
padding-bottom:0 !important;
height: 120px;
}
.navbar a {
color: #fff !important;
text-transform: uppercase;
font-size: 14px;
font-weight: 300px;
font-family: 'Oswald', sans-serif;
text-decoration: none;
}
.navbar a:hover{
color:#258faf !important;
}
.navbar {
border: 0px;
}
.logo {
display: block;
text-decoration: none;
max-height: 95px;
margin: 12px 0px 0px 0px;
width: auto;
}
#media (max-width: 960px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
margin-top: 40px;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
You can simple place your link rules inside of a media query:
#media (min-width: 960px) {
.navbar.navbar-tall .navbar-nav > li > a {
padding-top: 50px;
padding-bottom: 0;
height: 120px;
}
}
This example keeps the link height at the default settings once the navbar has collapsed.
Working Example: Open Example with FullPage and reduce the browser size.
.navbar.navbar-tall {
background-color: rgba(0, 0, 0, .6);
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, .1);
min-height: 120px;
border: 0px;
}
.navbar.navbar-tall .navbar-nav > li > a {
color: #fff;
text-transform: uppercase;
font-size: 14px;
font-weight: 300px;
font-family: 'Oswald', sans-serif;
text-decoration: none;
}
.navbar.navbar-tall .navbar-nav > li > a:hover {
color: #258faf;
}
.navbar.navbar-tall .navbar-brand {
padding-top: 50px;
padding-bottom: 0;
height: 120px;
}
#media (min-width: 960px) {
.navbar.navbar-tall .navbar-nav > li > a {
padding-top: 50px;
padding-bottom: 0;
height: 120px;
}
}
#media (max-width: 959px) and (min-width: 768px) {
.navbar.navbar-fixed-bottom .navbar-collapse,
.navbar.navbar-fixed-top .navbar-collapse {
max-height: auto;
overflow-x: visible;
}
}
#media (max-width: 959px) {
.navbar .navbar-header {
float: none;
}
.navbar .navbar-left,
.navbar .navbar-right {
float: none !important;
}
.navbar .navbar-right {
margin-right: 0px;
}
.navbar .navbar-right~.navbar-right {
margin-right: 0;
}
.navbar .navbar-toggle {
display: block;
margin-top: 42.50px;
}
.navbar .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar .navbar-collapse.collapse {
display: none!important;
overflow: visible!important;
}
.navbar .navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar .navbar-nav>li {
float: none;
}
.navbar .navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar .collapse.in {
display: block !important;
overflow-y: auto;
}
.navbar .navbar-nav .dropdown-menu > li > a,
.navbar .navbar-nav .dropdown-menu > li > a:hover,
.navbar .navbar-nav .dropdown-menu > li > a:focus {
color: #777;
}
.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;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-fixed-top navbar-tall">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav navbar-right">
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
</ul>
</div>
</div>
</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.7/js/bootstrap.min.js"></script>
it is normal that the height you put for large screen for the navbar (120px) will be seen in the small devices.
Keep the height of the Navbar small.
Incase if you want to increase height of navbar in large device you can play with
padding of the <a> (anchor inside the nav)
If you observe the toggle button in html it throws a class;
class="navbar-toggle collapsed" data-toggle="collapse"
and when the toggle-button is open it throws the class as;
class="navbar-collapse collapse in"
now according to as above class you can style your navbar <a>tags.
i hope this heps you in something to trying to achieve.
I am using the below css in my code to achieve a transparent white navbar but after collapsing menu in mobile version background style doesn't work. please help me to overcome this issue. i tried most of the solutions found in other questions
#header_wrapper {
background: rgba(255, 255, 255, 0.82);
}
.header_box {
position: relative;
}
.header{
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 15px 0px 10px 0px;
z-index: 10000;
transition: all 0.2s ease-in;
height: 100px;
background-color:transparent;
text-align: center;
line-height: 40px;
}
.header.active {
background: rgba(255, 255, 255, 0.82);
}
.logo {
float: left;
position: relative;
z-index: 2;
}
.res-nav_click {
display: none;
}
/* Nav Styles
---------------------------------*/
.navbar-inverse {
background-color: transparent;
border-color: transparent;
}
.navbar {
border: 0px solid #fff;
min-height: 40px;
margin-bottom: 0px;
}
.navbar-inverse .navbar-nav > li > a {
color: #000;
}
.navStyle {
float: right;
}
.navStyle ul {
list-style: none;
padding: 0px;
margin-top:25px;
}
.navStyle ul li {
display: inline-block;
margin: 0 5px;
}
.navStyle ul li:first-child {
/*margin:0px;*/;
}
.navStyle ul li:last-child {
margin: 0 0 0 23px;
}
.navStyle ul li a {
display: block;
font-size: 15px;
color: #222222;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
text-decoration: none;
text-transform: uppercase;
font-weight: 300;
transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out;
}
.navStyle ul li a:hover {
color: #ffc000;
border: 0px solid #fff;
}
.navStyle > li > a:hover, .nav > li > a:focus {
text-decoration: none;
color: #ffc000;
background-color: transparent;
}
.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus {
color: #ffc000;
background-color: transparent;
}
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
color: #ffc000;
background-color: transparent;
}
.navStyle > li.active > a,
.navStyle > li.active > a:hover {
text-decoration: none;
color: #ED5441;
background-color: transparent;
}
HTML:
<header id="header_wrapper" class="header active border">
<div class="container">
<div class="header_box">
<div class="logo"><img src="images/logo.png" alt="logo"></div>
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<button type="button" id="nav-toggle" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav"> <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 id="main-nav" class="collapse navbar-collapse navStyle">
<ul class="nav navbar-nav" id="mainNav">
<li class="active">Home
Home
</li>
<li>About Us
About Us
</li>
<li>Products
Products
</li>
<li>Services
Services
</li>
<li>Group
Group
</li>
<li>Careers
Career
</li>
<li>Contact Us
Contact Us
</li>
</ul>
</div>
</nav>
</div>
</div>
</header>
http://globaltrendz.com/blackandgreen/ please refer this one by changing header-wrapper bgcolor opactiy. like this one what i need
I am assuming that you want mobile navbar after 765px so you need to use a media query on that.
Add this at the end of your css file:
#media screen and (max-width: 765px){
.navStyle ul{
position: fixed;
left: 0;
background: rgba(255, 255, 255, 0.82) !important; //important //because you have inline styles.
}
}
Here's the output:
got the solution by applying below styles
.navbar-inverse {
background-color: rgba(222,222,222,0.84);
border-color: transparent;
width:100%;
position:fixed;
left:0;
}
.navStyle ul {
background-color: rgba(222,222,222,0.84);
}
I am working on bootstrap 3.0. I have a little problem that I want to remove the active background color of nav dropdown. See the image below...
I have tried alot but did not find the bootstrap css which remove this grey color. Can anybody please tell me that how to remove this as I am new to bootstrap. Thanks in advance.
Updated
Please see the code below.
<nav class="navbar yamm navbar-default" role="navigation" style="height:0px;">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-2">
<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 glyphicon glyphicon-home" href="#" style="left: 40px;"></a>
</div>
<div id="navbar-collapse-2" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown yamm-fw" style="border-left: 1px dotted #ccc;margin-left: -40px;">Electronics<b class="caret"></b>
<ul class="dropdown-menu" style="width:35%; left:125px; top:30px;">
<li>
<div class="yamm-content" style="width:200%;margin-top: 20px;">
<div class="row">
<div class="col-xs-6 col-sm-2"><img alt="150x190" src="images/electronics/laptops.png">
<p class="navbar-txt" style="margin-top: -150px;float: left;">Laptops & Computers</p>
<button class="btn btn-default navbar-btn">Explore</button>
</div>
<div class="col-xs-6 col-sm-2"><img alt="150x190" src="images/electronics/projectors.png"> <p class="navbar-txt" style="margin-top: -140px;float: left;">Tv & Projectors</p>
<button class="btn btn-default navbar-btn">Explore</button>
</div>
<div class="col-xs-6 col-sm-2"><img alt="150x190" src="images/electronics/tablets.png">
<p class="navbar-txt" style="margin-top: -140px;float: left;">Mobiles & Tablets</p>
<button class="btn btn-default navbar-btn">Explore</button>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div>
</nav>
Update 2# (CSS code)
#charset "utf-8";
/* CSS Document */
.navbar-brand {
float: left;
height: 83px;
width:125px;
padding: 15px 15px;
font-size: 18px;
line-height: 20px;
margin-left:20px;
}
.glyphicon1 {
position: relative;
left: -5px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-left: 10px;
}
.dropdown-menu {
left: 250px;
}
.divider1{
height: 1px;
margin: 35px 0;
overflow: hidden;
background-color: #e5e5e5;
}
.dropdown-header1 {
display: block;
padding: 3px 20px;
font-size: 12px;
line-height: 1.42857143;
color: #777;
white-space: nowrap;
margin-top: -25px;
color: #428bca;
font-size: 18px;
font-weight: bold;
}
.divider2{
height: 1px;
margin: 62px 0;
overflow: hidden;
background-color: #e5e5e5;
}
.dropdown-header2 {
display: block;
padding: 3px 20px;
font-size: 12px;
line-height: 1.42857143;
color: #777;
white-space: nowrap;
margin-top: -52px;
color: #428bca;
font-size: 18px;
font-weight: bold;
}
.divider3{
height: 1px;
margin: 35px 0;
overflow: hidden;
background-color: #e5e5e5;
}
.dropdown-header3 {
display: block;
padding: 3px 20px;
font-size: 12px;
line-height: 1.42857143;
color: #777;
white-space: nowrap;
margin-top: -25px;
color: #428bca;
font-size: 18px;
font-weight: bold;
}
#import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700);
body {
font-family: 'Open Sans', 'sans-serif';
}
.navbar-nav>li>.dropdown-menu {
margin-top:20px;
border-top-left-radius:4px;
border-top-right-radius:4px;
}
.navbar-default .navbar-nav>li>a {
width:200px;
font-weight:bold;
}
.mega-dropdown {
position: static !important;
width:100%;
}
.mega-dropdown-menu {
padding: 20px 0px;
width: 70%;
box-shadow: none;
-webkit-box-shadow: none;
}
.mega-dropdown-menu:before {
content: "";
border-bottom: 15px solid #fff;
border-right: 17px solid transparent;
border-left: 17px solid transparent;
position: absolute;
top: -15px;
left: 285px;
z-index: 10;
}
.mega-dropdown-menu:after {
content: "";
border-bottom: 17px solid #ccc;
border-right: 19px solid transparent;
border-left: 19px solid transparent;
position: absolute;
top: -17px;
left: 283px;
z-index: 8;
}
.mega-dropdown-menu > li > ul {
padding: 0;
margin: 0;
}
.mega-dropdown-menu > li > ul > li {
list-style: none;
}
.mega-dropdown-menu > li > ul > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #999;
white-space: normal;
}
.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
text-decoration: none;
color: #444;
background-color: #f5f5f5;
}
.mega-dropdown-menu .dropdown-header {
color: #428bca;
font-size: 18px;
font-weight:bold;
}
.mega-dropdown-menu form {
margin:3px 20px;
}
.mega-dropdown-menu .form-group {
margin-bottom: 3px;
}
.custom-search-form{
margin-top:5px;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus{
color: #555;
background-color: blue; //color change
}
EDIT: something like this? http://jsfiddle.net/swm53ran/203/
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus{
color: #555;
background-color: blue; //color change
}
if bootsrap theme min included then you have to add the following css
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus{
background-image:none;
color: #fff;
background-color: rgba(0,0,0,0.5);
}