I have a Bootstrap menu that that is slightly aligned to the left for some reason, I can't debug it. It doesn't have any rows, but the container is fluid and changing this to fixed makes it unresponsive in mobiles.
This is the live example. https://codepen.io/anon/pen/qjKbQM
This is the HTML code:
<nav class="navbar navbar-default" style="border:1px solid red";>
<div class="container-fluid">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#">UP</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><span class="glyphicon glyphicon-th" aria-hidden="true"></span> DEVIS GRATUIT</li>
<li class="dropdown">
Nos Ressource <span class="caret"></span>
<ul class="dropdown-menu">
<li>
Toutes nos ressources
</li>
<li>
Fiches conseils
</li>
<li>
Fiches métiers
</li>
<li>
Foire aux questions
</li>
<li>
Revue de presse
</li>
<li>
Le Blog
</li>
</ul>
</li>
<li class="dropdown">
Nos Fonctionalites <span class="caret"></span>
<ul class="dropdown-menu">
<li>
Toutes nos fonctionnalités
</li>
<li class="">
Mes indicateurs
</li>
<li class="">
Ma comptabilité
</li>
<li class="">
Mes devis et factures
</li>
<li class="">
Mon budget
</li>
<li>
Mon social-RH
</li>
<li class="">
Mon coffre-fort
</li>
</ul>
</li>
<li>Accounts</li>
<li class="dropdown">
Notre Cabinet <span class="caret"></span>
<ul class="dropdown-menu">
<li>
Tout sur notre cabinet
</li>
<li class="">
Qui sommes-nous ?
</li>
<li>
Pourquoi nous choisir ?
</li>
<li>
Comment devenir client ?
</li>
<li>
Notre équipe
</li>
<li>
Vos questions, nos réponses
</li>
<li class="">
Témoignages clients
</li>
<li class="">
Recrutement
</li>
</ul>
</li>
<li class="dropdown">
Nos Solutions <span class="caret"></span>
<ul class="dropdown-menu">
<li>
Toutes nos solutions
</li>
<li class="">
TPE / Consultants
</li>
<li>
Porteurs de projet
</li>
<li>
SCI / Locations meublées
</li>
<li class="">
Paye des salariés
</li>
<li class="">
Professions Libérales
</li>
<li class="">
Associations
</li>
<li class="">
Toutes nos solutions
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div>
</div><!-- /.container-fluid -->
</nav>
And this is the css :
.navbar-default {
font-size: 1.15em;
font-weight: 400;
border: 0px;
border-radius: 0px;
background: #021a2f !important;
}
.navbar-default .navbar-nav>li>a {
color: white;
}
.navbar-default .navbar-nav>li>a:hover {
color: #cbf0ff;
}
.navbar-default .navbar-brand {
color: #002433;
}
.navbar-default .navbar-brand:hover {
color: #ffffff;
text-shadow: 1px -1px 8px #b3e9ff;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus {
background-color: #004059;
color: white;
}
.navbar-default .navbar-toggle {
border: none;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border: none;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background-color: #002433;
}
.navbar-default .navbar-toggle .icon-bar {
}
.dropdown-menu {
background-color: #004059;
color: white;
border: 0px;
border-radius: 2px;
padding-top: 10px;
padding-bottom: 10px;
}
.dropdown-menu>li>a {
background-color: #004059;
color: white;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
background-color: #004059;
color:white;
}
.dropdown-menu .divider {
height: 1px;
margin: 9px 0;
overflow: hidden;
background-color: #003246;
}
.navbar-default .navbar-nav .open .dropdown-menu>li>a {
color: #ffffff;
}
#media (max-width: 767px) {
.dropdown-menu>li>a {
background-color: #006b96;
color: #ffffff;
}
.dropdown-menu>li>a:hover {
color: #ffffff;
}
.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus, .navbar-default .navbar-nav .open .dropdown-menu>li>a:hover {
color: #ffffff;
background-color: transparent;
}
.dropdown-menu .divider {
height: 1px;
margin: 9px 0;
overflow: hidden;
background-color: #005577;
}
}
How can I make the menus be centered without loosing the responsiveness of the navbar?
Add below css to get
.nav.customCl {
display: flex;
justify-content: center;
align-items: center;
flex-flow: row wrap;
}
And use this class in following html
<ul class="nav navbar-nav customCl"
codepen link
Related
I've gotten the following code to look as I want it, except I need the last two nav bar items to align far right.
I can make that happen with ul {text-align: right; width: 100%; background-color: #48C2C5;}, but when I do that, it alters the size of my dropdown menus.
I've attached a few pictures along with the code.
I'm doing this in Springshare Libguides.
Nav bar without far right 2 aligned right:
Cut off dropdown menu:
<style>
.s-lib-box {border-color: none; border-width: 0; box-shadow: none; background-color: none;}
.s-lib-box .s-lib-box-title {display: none;}
.s-lib-box .s-lg-box-footer {display: none;}
body {padding-left: 0; padding-right: 0;}
#s-lib-public-main a {color: #17365D;}
#s-lib-public-main a:visited {color: #2293c0;}
/*ABC Header*/
#header-abc {background-color: #ffffff; width: auto; }
#banner-abc {height: 110px; width: 1200px; margin-left: auto; margin-right: auto;}
#logo-abc {float: left; margin-left: 12px; margin-top: 10px;}
#search-cat {margin-top: 15px; padding: 0px 0px; text-align: right;}
#translate {padding: 2px 0px;}
#google_translate_element {width: 160px; margin: 15px 0;}
/*Menu*/
.caret{solid #ffffff;}
#menu-abc .navbar .nav > li > a, .navbar .nav > li > a:first-letter,
.navbar .nav > li.current-menu-item > a,
.navbar .nav > li.current-menu-ancestor > a {
}
#menu-abc .navbar .nav > li > a, .navbar .nav > li > a:first-letter {
color: white;
text-shadow: none;
}
#menu-abc .navbar .nav > li > a:hover, .navbar .nav > li > a:hover:first-letter {
color:#006699;
text-shadow: none;
}
#menu-abc .navbar .nav > li > a:active, .navbar .nav > li > a:active:first-letter,
.navbar .nav > li.current-menu-item > a,
.navbar .nav > li.current-menu-ancestor > a,
.navbar .nav > li.current-menu-item > a:first-letter,
.navbar .nav > li.current-menu-ancestor > a:first-letter {
color:#0099CC;
text-shadow: none;
}
#menu-abc .dropdown-menu > li > a {
color: #48C2C5;
background: white;
}
.dropdown ul li {
color:#0099CC;
}
#menu-abc .dropdown ul ul li a {
font-size:14px;
color:#0099CC;
}
#menu-abc .navbar .nav > li.current-menu-item > a, .navbar .nav > li.current-menu-ancestor > a,
.navbar .nav > li > a:hover, .navbar .nav > li > a:focus {
color: #red;
}
#menu-abc {background-color: #48C2C5; border-bottom: none;box-shadow: 3px 3px 10px 1px #green;}
#menu-abc .container-fluid {padding: 20;}
#menu-abc .navbar { min-height: 15px; background-color: #48C2C5;}
#menu-abc a {padding-right: 0px; font-family: Perpetua; font-size: 18px; font-weight: bold;}
#menu-abc a:hover {color: #red;}
.dropdown:hover .dropdown-menu {font-size: 14px; display: inline; }
.dropdown-menu > li > a {
background: #48C2C5;
border-bottom: none; }
#menu-abc {background-color: #48C2C5; border-bottom: none;box-shadow: 3px 3px 10px 1px #white;}
#menu-abc .container-fluid {padding: 0;}
#menu-abc .navbar { min-height: 15px; background-color: #48C2C5;}
#menu-abc a {padding-right: 25px; font-family: Perpetua; font-size: 18px; font-weight: bold;}
#menu-abc a:hover {color: #red;}
#menu-abc .dropdown:hover .dropdown-menu {display: block;}
.dropdown-content {
min-width: 160px;}
#menu-abc .navbar-default .navbar-collapse, #menu-abc .navbar-default .navbar-form {background-color: #48C2C5;}
#menu-abc .navbar-default {width: auto; margin-left: auto; margin-right: auto; border: none;}
#menu-abc .dropdown-menu a {color:#0099CC;}
#menu-abc .dropdown-menu a:hover {background-color: #yellow;}
#menu-abc .dropdown-menu .divider {background-color: #48C2C5;}
#menu-abc .navbar-default .navbar-nav > .open > a {color: #48C2C5; background-color: #yellow;}
#menu-abc .navbar-default .navbar-nav > li.open > a {color: #yellow; background-color: #48C2C5;}
#menu-abc .navbar-nav .dropdown:hover > a[data-toggle=dropdown] + .dropdown-menu {display: block;}
#menu-abc .navbar-nav .dropdown.open > a[data-toggle=dropdown] + .dropdown-menu {display: block;}
/*Main Content Area*/
#s-lib-public-main .row {margin-bottom: 30px; margin-left: 5px;}
<title></title>
</head>
<body class="s-lg-guide-body">
<!-- BEGIN: Page Header -->
<meta content="97a72cc605382e45-5c9ddd9618eb904f-gad80e90ba61d526a-e" name="google-translate-customization">
<div id="header-abc">
<div class="container-fluid" id="banner-abc">
<div class="row">
<div class="col-sm-6 center" id="col1">
<div class="row">
<div class="col-md-6" id="logo-abc">
<img height="100" src="https://libapps.s3.amazonaws.com/accounts/27400/images/bunche_new_logo.jpg">
</div><!--/logo-abc=-->
</div><!--/row-->
</div><!--/col1-->
<div class="col-sm-6" id="col0">
<div class="row">
<div class="col-md-7" id="search-cat">
<br>
</div><!--/row-->
</div><!--/col2-->
</div>
</div><!--/banner-abc-->
</div><!-- Menu -->
<div id="menu-abc">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle" data-target="#abc-navbar-collapse-1" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
</div><!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="abc-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
My Account
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Find<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Catalog
</li>
<li>
Library Map
</li>
<li class='sub'>
Databases
<ul>
<li>
Current Trials
</li>
</ul>
<ul>
<li>
Direct Access Resources
</li>
</ul>
</li>
<li>
Find a Journal
</li>
<li>
Ebooks
</li>
<li>
Virtual Periodical Reading Room
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Get Help<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Research & Instruction Services
</li>
<li>
Ebook Virtual Library
</li>
<li>
Virtual Libraries
</li>
<li>
A - Z Journal List
</li>
<li>
Bibliographies
<ul>
<li>
Foreign Affairs Professional Reading List
</li>
</ul>
</li>
<li>
<a>Briefing Videos</a>
</li>
<li>
Copyright
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Library Services<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
My Library Account
<ul>
<li>
How to Create an Account
</li>
</ul>
</li>
<li>
Acquisitions and Procurement
<ul>
<li>
DS-2092
</li>
</ul>
</li>
<li>
Interlibrary Loan
</li>
<li>
Map Services
</li>
<li>
Instruction
</li>
<li>
Donations
</li>
<li>
Booking the Rare Book Room
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About Us<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Mission and Vision
</li>
<li>
Library Staff
</li>
<li>
Policies
<ul>
<li>
Circulation
</li>
</ul>
<ul>
<li>
Collection Development
</li>
</ul>
</li>
<li>
Who was Ralph Bunche?
</li>
<li>
Rare Book Collection
</li>
<li>
5 FAM 1400
</li>
<li class="divider"></li>
<li>
Office of Information Programs and Services
</li>
</ul>
</li>
<li style="float:right;">
<a href="#</a>
</li>
<li style="float:right;">
A/GIS/IPS
</li>
</ul><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
</div><!-- END: Page Header Without Encore -->
<!-- END: Page Header -->
</div>
</body>
</html>
I know LibGuides use Bootstrap 3, so instead of the float right on the last two list items, I've placed a pull-right class. I also set the UL element to stretch to 100%. The answer below only includes the HTML, not the CSS, but give it a try:
<div id="header-abc">
<div class="container-fluid" id="banner-abc">
<div class="row">
<div class="col-sm-6 center" id="col1">
<div class="row">
<div class="col-md-6" id="logo-abc">
<img height="100" src="https://libapps.s3.amazonaws.com/accounts/27400/images/bunche_new_logo.jpg">
</div><!--/logo-abc=-->
</div><!--/row-->
</div><!--/col1-->
<div class="col-sm-6" id="col0">
<div class="row">
<div class="col-md-7" id="search-cat">
<br>
</div><!--/row-->
</div><!--/col2-->
</div>
</div><!--/banner-abc-->
</div><!-- Menu -->
<div id="menu-abc">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle" data-target="#abc-navbar-collapse-1" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
</div><!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="abc-navbar-collapse-1">
<ul class="nav navbar-nav" style="width:100%;">
<li>
My Account
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Find<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Catalog
</li>
<li>
Library Map
</li>
<li class='sub'>
Databases
<ul>
<li>
Current Trials
</li>
</ul>
<ul>
<li>
Direct Access Resources
</li>
</ul>
</li>
<li>
Find a Journal
</li>
<li>
Ebooks
</li>
<li>
Virtual Periodical Reading Room
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Get Help<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Research & Instruction Services
</li>
<li>
Ebook Virtual Library
</li>
<li>
Virtual Libraries
</li>
<li>
A - Z Journal List
</li>
<li>
Bibliographies
<ul>
<li>
Foreign Affairs Professional Reading List
</li>
</ul>
</li>
<li>
<a>Briefing Videos</a>
</li>
<li>
Copyright
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Library Services<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
My Library Account
<ul>
<li>
How to Create an Account
</li>
</ul>
</li>
<li>
Acquisitions and Procurement
<ul>
<li>
DS-2092
</li>
</ul>
</li>
<li>
Interlibrary Loan
</li>
<li>
Map Services
</li>
<li>
Instruction
</li>
<li>
Donations
</li>
<li>
Booking the Rare Book Room
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About Us<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Mission and Vision
</li>
<li>
Library Staff
</li>
<li>
Policies
<ul>
<li>
Circulation
</li>
</ul>
<ul>
<li>
Collection Development
</li>
</ul>
</li>
<li>
Who was Ralph Bunche?
</li>
<li>
Rare Book Collection
</li>
<li>
5 FAM 1400
</li>
<li class="divider"></li>
<li>
Office of Information Programs and Services
</li>
</ul>
</li>
<li class="pull-right">
Knowledge Portal
</li>
<li class="pull-right">
A/GIS/IPS
</li>
</ul><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
</div><!-- END: Page Header Without Encore -->
<!-- END: Page Header -->
</div>
You problem is with this css code:
ul {text-align: right; width: 100%; background-color: #48C2C5;}
It will affected all the same element or recursively to all it's child element.
To solved this you can add additional id or class on the affected element to make it unique:
ul.unique {text-align: right; width: 100%; background-color: #48C2C5;}
or overwrite style on unwanted affected element only:
ul li.sub-menu {text-align: left;}
i'm using twitter bootstrap and wish to have a number of drop-down sub menus. Problem is I want my 'mega-dropdown-menu' to be 100% width of the page yet all the others need to remain at 180px. Currently the mega-dropdown menu is either confined by the width of the <li> element that triggers it OR the default width used by all the normal dropdown-menus (180px).
I have tried using !important on the 'mega-dropdown menu' class. I have also tried removing a width and setting left and right to 'auto'. When i just use 100% it is contained by the parent <li>
I'd also like to make the arrow appear to point at the <li> that triggered the mega-dropdown menu.
.container {
width:100% !important;
padding: 0px;
margin: 0px;
}
/*START MEGA MENU CSS*/
.dropdown-menu {
width: 150px !important;
background: #45484d; /* Old browsers */
background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6-15
*/
background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}
.dropdown-menu>li>a {
color: #fff !important;
}
.dropdown-header1 {
font-size:16px;
font-weight:bold !important;
color: #F58220 !important;
padding-left: 17px !important;
}
.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: 150px;
font-weight: bold;
}
.mega-dropdown {
position: relative !important;
width: 180px;
}
.mega-dropdown-menu {
padding: 20px 0px;
width: 1000px !important;
left:auto;
right:auto;
overflow:visible;
box-shadow: none;
-webkit-box-shadow: none;
background-color:#000000;
}
.mega-dropdown-menu:before {
content: "";
border-bottom: 15px solid #43464b;
border-right: 17px solid transparent;
border-left: 17px solid transparent;
position: absolute;
top: -15px;
left: 0px;
z-index: 10;
}
.mega-dropdown-menu:after {
content: "";
border-bottom: 17px solid #43464b;
border-right: 19px solid transparent;
border-left: 19px solid transparent;
position: absolute;
top: -17px;
left: 0px;
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: #fff;
white-space: normal;
}
.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
text-decoration: none;
color: #000;
background-color: #f5f5f5;
}
.mega-dropdown-menu .dropdown-header {
color: #428bca;
font-size: 1.2em;
font-weight: bold;
}
.mega-dropdown-menu form {
margin: 3px 20px;
}
.mega-dropdown-menu .form-group {
margin-bottom: 3px;
}
.divider {
border-bottom:dotted 1px #ccc !important;
}
The HTML is pretty standard as you can see too:
I'd be grateful for any input on this as its driving me nuts!! Quite happy to start again if my approach is way off to start with? Not overly concerned about how it is handled on mobile as I will be hiding the mega-menu on smaller devices and replacing with a vanilla 'dropdown-menu'.
<!-- Navigation -->
<!-- Fixed navbar -->
<nav id="header" class="navbar navbar-fixed-top">
<div id="header-container" class="container navbar-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 id="brand" class="navbar-brand" href="/"><img src="https://www.inciner8.com/images/full-logo-white.png" width="160" height="25"></a>
</div>
<div id="navbar" class="collapse navbar-collapse pull-right">
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
INCINERATORS <b class="caret"></b>
<ul class="dropdown-menu mega-dropdown-menu row">
<li class="col-sm-3">
<ul>
<li class="dropdown-header">Most Popular</li>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/254x150/3498db/f5f5f5/&text=i8M-60+Medical" class="img-responsive" alt="product 1">
<h4><small>Self-contained Medical Incinerator</small></h4>
<button class="btn btn-primary" type="button">GET a Quote</button>
<button href="#" class="btn btn-default" type="button"><span class="glyphicon glyphicon-heart"></span> more info...</button>
</div>
<!-- End Item -->
<div class="item">
<img src="http://placehold.it/254x150/ef5e55/f5f5f5/&text=Large+Capacity" class="img-responsive" alt="product 2">
<h4><small>Our Flagship 1 Tonne Incinerator</small></h4>
<button class="btn btn-primary" type="button">GET a Quote</button>
<button href="#" class="btn btn-default" type="button"><span class="glyphicon glyphicon-heart"></span> more info...</button>
</div>
<!-- End Item -->
<div class="item">
<img src="http://placehold.it/254x150/2ecc71/f5f5f5/&text=Dual+Chamber" class="img-responsive" alt="product 3">
<h4><small>Hot Hearth Designed Dual Chamber Pet Cremator</small></h4>
<button class="btn btn-primary" type="button">GET a Quote</button>
<button href="#" class="btn btn-default" type="button"><span class="glyphicon glyphicon-heart"></span> more info...</button>
</div>
<!-- End Item -->
</div>
<!-- End Carousel Inner -->
</div>
<!-- /.carousel -->
</ul>
</li>
</ul>
</li>
<li class="dropdown">
PET CREMATION <b class="caret"></b>
<ul class="dropdown-menu">
<li>Dual Chamber Pet Cremator <span class="badge badge-important pull-right">New!</span></li>
<li>Horse Cremator</li>
<li>Heat Exchangers</li>
<li>Pet Cremation Accessories</li>
<li class="divider"></li>
<li class="dropdown-header1">Want to learn more?</li>
<li>Starting a Pet Crematorium</li>
<li>Pet Cremation Business Plan</li>
<li>Pet Cremation Business Franchise</li>
</ul>
</li>
<li class="dropdown">
WASTE TO ENERGY <b class="caret"></b>
<ul class="dropdown-menu">
<li>EFW-40</a></li>
<li>EFW-20</li>
<li>Heat Exchangers</li>
<li>Organic Ranking Cycle Engine</li>
<li class="divider"></li>
<li class="dropdown-header1">Want to learn more?</li>
<li>What is W2E?</li>
<li>Use Incinerators to Create Electricity</li>
</ul>
</li>
<li class="dropdown">
POLLUTION CONTROL <b class="caret"></b>
<ul class="dropdown-menu">
<li>Small PCS</li>
<li>Large PCS</li>
<li>Venturi Scrubber</li>
<li class="divider"></li>
<li class="dropdown-header1">Want to learn more?</li>
<li>Ceramic Filters</a></li>
<li>Activated Carbon Filters</li>
<li>Lime Feed</li>
<li>What are Acceptable Emission Levels?</li>
</ul>
</li>
<li class="dropdown">
INCINERATION <b class="caret"></b>
<ul class="dropdown-menu">
<li>How it Works</a></li>
<li>Types of Incinerator</li>
<li>What you Can/Cannot Burn</li>
<li>Legislation</li>
<li class="divider"></li>
<li class="dropdown-header1">Want to Learn More?</li>
<li>Read our Blog...</li>
</ul>
</li>
<li class="dropdown">
SUPPORT <b class="caret"></b>
<ul class="dropdown-menu">
<li>Download Brochures & Datasheets <span class="badge badge-important pull-right">New!</span></li>
<li>Emissions Quick Reference</li>
<li>Fuel Consumption Quick Reference</li>
<li>Dealer Resources</li>
<li class="divider"></li>
<li class="dropdown-header1">Useful Resources</li>
<li>Visit our <strong>spare parts website</strong></li>
<li>Activate your Warranty</li>
<li>Become a Dealer</li>
<li>Become a Dealer</li>
<li class="divider"></li>
<li class="dropdown-header1">FREE Waste Audit Templates <span class="badge badge-important pull-right">New!</span></li>
<li>Waste Audit</li>
<li>Waste Logbook</li>
<li>Medical Waste Logbook</li>
<li>Animal Waste Logbook</li>
</ul>
</li>
<li class="dropdown">
ABOUT <b class="caret"></b>
<ul class="dropdown-menu">
<li>Company History <span class="badge badge-important pull-right">New!</span></li>
<li>Awards & Accreditations</li>
<li>The Team</li>
<li>News</li>
<li>Our Values</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</nav>
<!-- /.navbar -->
My navbar link "Services" is left aligned as compared to the other links. I want to align it with the rest.
I have tried Bootstrap NavBar not aligned, especially in mobile view but it doesn't help me in my scenario.
Please advise where am i going wrong.
Navbar
CSS:
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 10px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
padding: 13px 0px 10px 0px;
display; inline;
display: inline-block;
}
.dropdown:hover{
background-color:#37979f;
border:1px solid;
border-color: #fff;
border-radius:4px;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
margin-top: 10px;
display: none;
position: absolute;
background-color: #37979f;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
color: #ffffff;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
background-color: #37979f;
border:1px solid;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
HTML:
<div id="navbar" class="navbar-collapse collapse">
<ul class="navbar-right nav navbar-nav" style="background-color:#6FC2E3";>
<!-- Hidden li included to remove active class from about link when scrolled up past about section -->
<li class="active" >
<a class="page-scroll" href=".">Home</a>
</li>
<li>
<a class="page-scroll" href="./solutions">Solutions</a>
</li>
<li>
<div class="dropdown">
<a class="page-scroll" href="../services">Services</a>
<div class="dropdown-content">
<a class="page-scroll" href="../services/consulting.html">Consulting</a>
<a class="page-scroll" href="../services/development.html">Development</a>
<a class="page-scroll" href="../services/support.html">Support</a>
<a class="page-scroll" href="../services/managed-services.html">Managed Services</a>
</div>
</div>
</li>
<li>
<a class="page-scroll" href="./products">Products</a>
</li>
<li>
<a class="page-scroll" href="./blog">Blog</a>
</li>
<li>
<a class="page-scroll" href="./aboutus">About Us</a>
</li>
<li>
<a class="page-scroll" href="./contactus">Contact Us</a>
</li>
<li style="padding-top:13px;">
<font color="#DF0000 !important;" font size="4px;">Call: +61 449 176 002</font>
</li>
</ul>
</div>
why are you create new .dropdown class? already bootstrap have dropdown toogle refer this example it's working very well
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/>
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet"/>
<div class="navbar navbar-inverse ">
<div class="container">
<!-- Header -->
<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>
<a class="navbar-brand" href="#">Bootstrap</a>
</div>
<!-- Navbar Links -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Services
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Page 1-1</li>
<li>Page 1-2</li>
<li>Page 1-3</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
Please hvae a look at the below code
<div id="main-sidebar-wrapper" style="margin-top:50px; width:150px;">
<ul class="sidebar-nav" style="margin-top:10px;">
<!-- <li> Face Sheet </li> -->
<li class="li_active"> History </li>
<li> Problems </li>
<li> Medications </li>
<!-- <li> Immunizations </li> -->
<li > Allergies </li>
<li> Vitals </li>
<li> Examinations </li>
<li > Counseling </li>
<li> Demographics </li>
<hr>
<li>Documents Upload
<ul class="sub-menu">
<li>E.C.G</li>
</ul>
</li>
<!-- <li> Documents </li> -->
</ul>
</div>
Here, the Documents Upload section, I want it to be a drop-up menu or drop-right side menu. How can I do this?
#media (min-width: 768px) {
.navbar-collapse {
height: auto;
border-top: 0;
box-shadow: none;
max-height: none;
padding-left:0;
padding-right:0;
}
.navbar-collapse.collapse {
display: block !important;
width: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-x: visible;
}
.navbar
{
max-width:300px;
margin-right: 0;
margin-left: 0;
}
.navbar-nav,
.navbar-nav > li,
.navbar-left,
.navbar-right,
.navbar-header
{float:none !important;}
.navbar-right .dropdown-menu {left:0;right:auto;}
.navbar-collapse .navbar-nav.navbar-right:last-child {
margin-right: 0;
}
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Jquery CDN -->
<script src="https://code.jquery.com/jquery-2.1.2.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-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="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active">Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</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>
</div><!-- /.navbar-collapse -->
</nav>
Please find updated fiddle.
Need to do some change in
<li>Documents Upload
<ul class="sub-menu">
<li>E.C.G</li>
</ul>
</li>
I have made required changes. Please go through the link.
This is similar to how the dropdown menus work on mobile, may help.
body,
html {
height: 100%;
}
.sidebar-fixed {
padding: 5px 18px;
position: fixed;
width: 175px;
height: 100%;
top: 0;
left: 0;
background: #f5f5f5;
}
.sidebar-fixed #drop-one {
list-style: none;
text-align: left;
}
.sidebar-fixed #drop-one > li {
padding-top: 10px;
font-size: 13px;
}
.sidebar-fixed #drop-one > li >a {
color: #555;
text-decoration: none;
}
ul.sidebar-list {
list-style: none;
display: inline;
text-align: left;
}
ul.sidebar-list > li {
font-size: 18px;
padding-bottom: 25px;
}
ul.sidebar-list > li > a {
color: #555;
text-decoration: none;
}
.main-content {
margin-left: 175px;
padding-top: 5px;
}
<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" />
<div class="sidebar-fixed" id="sideNavParent">
<ul class="sidebar-list">
<li> Sidebar
</li>
<li> Something
</li>
<li> Something <span class="caret"></span>
<ul id="drop-one" class="collapse" data-parent="#sideNavParent">
<li> Something
</li>
<li> Something
</li>
<li> Something
</li>
<li> Something
</li>
</ul>
</li>
</ul>
</div>
<div class="main-content">
<div class="container-fluid">
<div class="alert alert-info">Main Content</div>
</div>
</div>
This is a problem , that I have: http://i.stack.imgur.com/i80Yl.jpg .
This is a part of Bootstrap menu.
Some more informations have been added
Header
<link rel="stylesheet" type="text/css" href="view/stylesheet/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="view/stylesheet/bootstrap.css" />
But when i want to overwrite any Bootstrap options i need to use !important. I dont want to change Bootstrap css.
HTML
<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="http://localhost/Web/E-Shop/admin/index.php?route=common/home&token=dac2fdfed5ea52154c40dd0ad17dbe92">Obchod</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
Catalog<b class="caret"></b>
<ul class="dropdown-menu">
<li> Categories</li>
<li>Products</li>
<li>Filters</li>
<li>Profiles</li>
<li class="divider"></li>
<li>Attributes</li>
<li>Attribute Groups</li>
<li class="divider"></li>
<li>Options</li>
<li>Manufacturers</li>
<li>Downloads</li>
<li>Reviews</li>
<li>Information</li>
</ul>
</li>
<li class="dropdown">
Extensions<b class="caret"></b>
<ul class="dropdown-menu">
<li>Modules</li>
<li>Shipping</li>
<li>Payments</li>
<li>Order Totals</li>
<li>Product Feeds</li>
</ul>
</li>
<li class="dropdown">
Sales<b class="caret"></b>
<ul class="dropdown-menu">
<li>Orders</li>
<li>Recurring Profiles</li>
<li>Returns</li>
<li class="divider"></li>
<li>Customers</li>
<li>Customer Groups</li>
<li>Banned IP</li>
<li class="divider"></li>
<li>Affiliates</li>
<li>Coupons</li>
<li class="divider"></li>
<li>Gift Vouchers</li>
<li>Voucher Themes</li>
<li class="divider"></li>
<li>Mail</li>
</ul>
</li>
<li class="dropdown">
System<b class="caret"></b>
<ul class="dropdown-menu">
<li>Settings</li>
<li class="divider"></li>
<li>Layouts</li>
<li>Banners</li>
<li class="divider"></li>
<li>Users</li>
<li>User Groups</li>
</ul>
</li>
<li class="dropdown">
Localisation<b class="caret"></b>
<ul class="dropdown-menu">
<li>Languages</li>
<li>Currencies</li>
<li>Stock Statuses</li>
<li>Order Statuses</li>
<li class="divider"></li>
<li>Return Statuses</li>
<li>Return Actions</li>
<li class="divider"></li>
<li>Countries</li>
<li>Zones</li>
<li>Geo Zones</li>
<li class="divider"></li>
<li>Tax Classes</li>
<li>Tax Rates</li>
<li class="divider"></li>
<li>Length Classes</li>
<li>Weight Classes</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Error Logs</li>
<li>Backup / Restore</li>
</ul>
</div><!--/.nav-collapse -->
</div>
CSS
.navbar-default {
background-color: #00598e !important;
border-color: none !important;
color: #fff !important;
}
.navbar-default .navbar-nav > li > a {
color: #fff !important;
}
.navbar-default .navbar-brand {
color: #FFF !important;
}
.dropdown .open{
}
.dropdown:hover .dropdown-menu {
display: block;
}
.dropdown:hover {
background-color: #0077c0;
}
.vertical-offset-100{
padding-top:100px;
}
.footer-s{
position:fixed;
left:0px;
bottom:0px;
width:100%;
}
.alert{
margin-top: 30px;
}
.nav .open>a, .nav .open>a:hover, .nav .open>a:focus {
background-color: #00598e;
border-color: #00598e;
}
.dropdown-menu>li>ul>li>a:hover, .dropdown-menu>li>ul>li>a:focus{
text-decoration: none;
color: #262626;
background-color: #F5F5F5;
}
.container{
margin-top: 50px;
}
.btn>a:hover,
.btn>a:focus,
.btn>a {
color: #fff;
text-decoration: none;
}
.scrollbox{
height: 120px;
width: auto;
border: 1px solid #ccc;
overflow: auto;
}
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
color: #FFF;
background-color: #0077c0 !important;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #FFF !important;
}
I suggest you move your override or custom stylesheet below (after) the boostrap CSS file. Then, you shouldn't need to use !important as much or ever. Just remember that you'll need to match or exceed the same specificity in your custom stylesheet to make overrides.
<link rel="stylesheet" type="text/css" href="view/stylesheet/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="view/stylesheet/stylesheet.css" /> <!-- moved below bootstrap.css -->