I'm so novice I'm not even sure of the terms and definitions.
All was working well, but I clearly broke something.
When I narrow the page completely, it is fine. When I expand completely, it is fine. But a few stages in between, the navbar dropdowns exceed the container and fly out to the right.
I did not alter any of the #media parameter that were prefabbed in this dreamweaver set up.
.nav {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.nav-link {
color: #FFCC00!important;
display: block;
padding: 0.5rem 1rem;
}
.nav-link:hover, .nav-link:focus {
color: #33ccff!important;
text-decoration: none;
}
.nav-link.disabled {
color: #6c757d;
pointer-events: none;
cursor: default;
}
.nav-tabs {
border-bottom: 1px solid #dee2e6;
}
.nav-tabs .nav-item {
margin-bottom: -1px;
}
.nav-tabs .nav-link {
border: 1px solid transparent;
border-top-left-radius: 0.25rem;
border-top-right-radius: 0.25rem;
}
.nav-tabs .nav-link:hover, .nav-tabs .nav-link:focus {
border-color: #e9ecef #e9ecef #dee2e6;
}
.nav-tabs .nav-link.disabled {
color: #6c757d;
background-color: transparent;
border-color: transparent;
}
.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
color: #495057;
background-color: #fff;
border-color: #dee2e6 #dee2e6 #fff;
}
.nav-tabs .dropdown-menu {
margin-top: -1px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.nav-pills .nav-link {
border-radius: 0.25rem;
}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
color: #fff;
background-color: #007bff;
}
.nav-fill .nav-item {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
text-align: center;
}
.nav-justified .nav-item {
-ms-flex-preferred-size: 0;
flex-basis: 0;
-ms-flex-positive: 1;
flex-grow: 1;
text-align: center;
}
.tab-content > .tab-pane {
display: none;
}
.tab-content > .active {
display: block;
}
.navbar {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: justify;
justify-content: space-between;
padding: 0.5rem 1rem;
}
.navbar .container,
.navbar .container-fluid, .navbar .container-sm, .navbar .container-md, .navbar .container-lg, .navbar .container-xl {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: justify;
justify-content: space-between;
}
.navbar-custom {
background-color: #0a0a0a;
}
/* change the brand and text color */
.navbar-custom .navbar-brand,
.navbar-custom .navbar-text {
color: rgba(243, 203, 4, 1);
}
/* change the link color */
.navbar-custom .navbar-nav .nav-link {
color: rgba(255,255,255,.5);
}
/* change the color of active or hovered links */
.navbar-custom .nav-item.active .nav-link,
.navbar-custom .nav-item:hover .nav-link {
color: #33ccff;
}
.navbar-brand {
display: inline-block;
padding-top: 0.3125rem;
padding-bottom: 0.3125rem;
margin-right: 1rem;
font-size: 1.25rem;
line-height: inherit;
white-space: nowrap;
}
.navbar-brand:hover, .navbar-brand:focus {
text-decoration: none;
}
.navbar-nav {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.navbar-nav .nav-link {
padding-right: 0;
padding-left: 0;
}
.navbar-nav .dropdown-menu {
position: static;
float: none;
}
.navbar-text {
display: inline-block;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.navbar-collapse {
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
-ms-flex-positive: 1;
flex-grow: 1;
-ms-flex-align: center;
align-items: center;
}
.custom-toggler .navbar-toggler {
color: rgba(255, 255, 255, 0.5);
border-color: #f3cb06;
background-color: #0A0A0A;
text-align: center
}
.custom-toggler .navbar-toggler-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(243,203,6,1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
/*change toggler color*/
.custom-toggler.navbar-toggler {
border-color: #ffcc00;
text-align: center;
}
/*end change toggler color but I need to change the toggler bg color*/
.navbar-toggler {
padding: 0.25rem 0.75rem;
font-size: 1.25rem;
line-height: 1;
background-color: transparent;
border: 1px solid transparent;
border-radius: 0.25rem;
}
.navbar-toggler:hover, .navbar-toggler:focus {
text-decoration: none;
}
.navbar-toggler-icon {
display: inline-block;
width: 1.5em;
height: 1.5em;
vertical-align: middle;
content: "";
background: no-repeat center center;
background-size: 100% 100%;
<div class="container-align align-content-center">
<div class="container align-content-center"><img src="images/CDBanner.png" alt="" width="100%" class="img-fluid" lass="img-fluid"/></div>
<div class="container-fluid">
<div class="container-fluid">
<div class="container">
<nav class="navbar navbar-expand-sm bg-custom navbar-custom">
<nav class="navbar navbar-expand-lg custom-toggler" style="background-color: rgb(10, 10, 10);">
<button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent1" aria-controls="navbarSupportedContent1" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent1">
<ul class="navbar-nav mr-auto">
<li class="nav-item active"> <a class="nav-link" href="#">Home<span class="sr-only">(current)</span></a> </li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Posters</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"> <a class="dropdown-item" href="#">QI Posters</a> <a class="dropdown-item" href="#">Case Studies Posters</a>
</div>
</li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Booklets & Brochures</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"><a class="dropdown-item" href="#">Booklets</a>
<a class="dropdown-item" href="#">Brochures</a></div>
</li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Logos & Illustrative</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"> <a class="dropdown-item" href="#">Logos</a> <a class="dropdown-item" href="#">Illustrative</a>
</div>
</li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Motion</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"> <a class="dropdown-item" href="#">Motion 1</a> <a class="dropdown-item" href="#">Motion 2</a>
<a class="dropdown-item" href="#">Motion 3</a>
<a class="dropdown-item" href="#">Motion 4</a></div>
</li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown5" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Social Media</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"> <a class="dropdown-item" href="#">Before & After Ads</a> <a class="dropdown-item" href="#">FaceBook & Instragram</a>
<a class="dropdown-item" href="#">YouTube Thumbnails</a></div>
</li>
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown6" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Other </a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1"> <a class="dropdown-item" href="#">Other</a> <a class="dropdown-item" href="#">Web Site and UI</a>
<a class="dropdown-item" href="#">T-Shirts</a></div>
</li>
<li class="nav-item"> </li>
</ul>
</div>
</nav>
</div>
I have been trying to center this navbar. It was centered navigation flying out to rightat one time and I don't know where that went.
But this is not coded the way the bootstrap site advises. I think I'm unwilling to redo it.
navigation expanded beyond container
Related
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
i just found an issue on my web project and i couldnt find a way around it.
i saw something about sprites and a blog that mentions this issue.
everything looks fine on 100% but when i zoom in with my browser the icons get bigger and bigger and break the layout.
this is what my css look like
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
Html (Angular) Code
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
example of the issue (Zoomlevel on 500%):
HTML:
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
CSS:
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
.sb-i i{
width: 100%;
height: auto;
}
.sb-i svg {
width: 100% !important;
height: auto !important;
}
I am using bootstrap. I need to make this responsive but i couldn't handle it. Specially search bar frustrate me.
I want menu elements collapsed under 992px. Waiting for suggestions. Thanks.
CodePen Link
Example Code:
nav.navbar-default {
background-color: #232323;
margin-right: 1px;
border: 0;
}
div.navbar-wrapper {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 20;
}
div.navbar-wrapper .container {
padding: 0;
}
div.navbar-wrapper .col {
padding: 0;
}
div.navbar-wrapper .col:first-child {
padding-right: 30px;
}
div.navbar-wrapper .menu-middle {
width: 64.66667%;
}
div.navbar-wrapper .menu-right {
width: 10.33333%;
}
div.navbar-wrapper .logo {
background: url(/assets/img/logo.png) center no-repeat;
background-color: #3d3d3d;
min-width: 100%;
min-height: 100%;
height: 134px;
}
div.navbar-wrapper .logo.navbar-brand {
margin-left: 0;
}
div.navbar-wrapper .logo:hover {
background-color: #3d3d3d;
}
div.navbar-wrapper .logo span.brand-name {
position: absolute;
}
div.navbar-wrapper .nav-wrap .top-nav {
height: 36px;
width: 100%;
display: block;
}
div.navbar-wrapper .nav-wrap .top-nav > li > a {
font-size: 12px;
color: #fff;
padding-top: 10px;
padding-bottom: 10px;
}
div.navbar-wrapper .nav-wrap .top-nav > li > a:hover {
color: #999;
}
div.navbar-wrapper .nav-wrap .top-nav > li > a .fa {
padding-right: 5px;
}
div.navbar-wrapper .nav-wrap .top-nav .dropdown {
background-color: #555555;
margin-right: 2.2px;
}
div.navbar-wrapper .nav-wrap .top-nav .navbar-form {
padding: 0;
margin: 0;
}
div.navbar-wrapper .nav-wrap .top-nav .nav-search-bar .form-control,
div.navbar-wrapper .nav-wrap .top-nav .nav-search-bar .btn-default {
background-color: #555555;
border: none;
-webkit-border-radius: 0;
border-radius: 0;
padding: 20px 32px;
color: #fff;
font-size: 14px;
}
div.navbar-wrapper .nav-wrap .top-nav .nav-search-bar .form-control:focus,
div.navbar-wrapper .nav-wrap .top-nav .nav-search-bar .btn-default:focus {
-webkit-box-shadow: none;
box-shadow: none;
}
div.navbar-wrapper .nav-wrap .top-nav .nav-search-bar .btn-default {
padding: 9px;
font-size: 16px;
outline: 0;
}
div.navbar-wrapper .nav-wrap .main-nav {
width: 100%;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
padding: 24px 0 24px 15px;
}
div.navbar-wrapper .nav-wrap .main-nav > li > a {
font-size: 14px;
font-weight: 700;
color: #fff;
-webkit-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
padding-left: 22px;
padding-right: 22px;
}
div.navbar-wrapper .nav-wrap .main-nav > li > a:hover {
background-color: #00a9df;
}
div.navbar-wrapper .nav-wrap .main-nav > li.active a {
background-color: #00a9df;
}
div.navbar-wrapper .nav-wrap .main-nav > li.active a:hover,
div.navbar-wrapper .nav-wrap .main-nav > li.active a:focus {
color: #fff;
}
div.navbar-wrapper .my-cart-wrap {
background-color: #ff9c00;
min-height: 100%;
height: 134px;
display: table;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap {
display: table-cell;
height: 100%;
text-align: center;
color: #fff;
vertical-align: middle;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap a {
color: #fff;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap a:hover {
text-decoration: underline;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap .fa-shopping-cart {
font-size: 18px;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap span.my-cart {
font-size: 14px;
}
div.navbar-wrapper .my-cart-wrap .shopping-cart-wrap span.cart-item {
font-size: 12px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<!-- NAVBAR -->
<div class="navbar-wrapper">
<div class="container">
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-default navbar-static-top">
<div class="container navbar-wrap">
<div class="navbar-header col col-md-3">
<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 logo" href="#"><span class="brand-name">Project name</span></a>
</div>
<div class="col col-md-8 menu-middle">
<div id="navbar" class="navbar-collapse collapse nav-wrap">
<ul class="nav navbar-nav top-nav">
<li><i class="fa fa-user" aria-hidden="true"></i>My Account
</li>
<li><i class="fa fa-heart" aria-hidden="true"></i>My Wishlist
</li>
<li><i class="fa fa-external-link" aria-hidden="true"></i>Checkout
</li>
<li class="dropdown">
USD <span class="caret"></span>
<ul class="dropdown-menu">
<li>TL
</li>
<li>EURO
</li>
</ul>
</li>
<li class="dropdown">
Turkish<span class="caret"></span>
<ul class="dropdown-menu">
<li>English
</li>
</ul>
</li>
<div class="input-group nav-search-bar">
<form class="navbar-form">
<input type="text" class="form-control" placeholder="Enter your keyword">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
</span>
</form>
</div>
</ul>
<ul class="nav navbar-nav main-nav text-uppercase">
<li class="active">Home
</li>
<li>Living Room
</li>
<li>Bedroom
</li>
<li>Dinning
</li>
<li>Blog
</li>
<li>Contact Us
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<div class="my-cart-wrap col col-sm-1 menu-right">
<div class="shopping-cart-wrap">
<a href="#">
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
<br>
<span class="my-cart">My Cart</span>
<br>
<span class="cart-item">0 Item</span>
</a>
</div>
</div>
</div>
</nav>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
Example:
Use this code for searchbar.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div class="input-group">
<input type="text" class="form-control" placeholder="Recipient's username" aria-describedby="basic-addon2">
<span class="input-group-addon" id="basic-addon2">#example.com</span>
</div>
Why text is not wrapping in IE10?
body{
background: url(http://i.imgur.com/ilgJJ1Q.gif);
margin: 0;
}
ul{
margin: 0;
padding: 0;
list-style: none;
display: flex;
height: 80px;
}
li{
display: flex;
}
ul a {
color: #fff;
display: flex;
-webkit-align-items: center;
align-items: center;
max-width: 240px;
padding: 12px 50px;
align-items: center;
text-transform: uppercase;
text-decoration: none;
}
li img{
border: 0;
margin-right: 10px;
}
li span span {
display: block;
height: 2px;
margin: 7px 0 -7px;
width: 25px;
}
li:last-child{
background: rgba(38, 46, 54, .6);
}
li:nth-child(2){ background: #a15796; }
li:nth-child(3){ background: #b48c4d; }
li:nth-child(4){ background: #3a7d7d; }
<ul class="top-level-tax">
<li>
<a href="#" >
<img src="http://i.imgur.com/SRVh4os.png">
<span>Lorem ipsum dolor<span style="background-color: #38729c;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/rBM2CYr.png">
<span>consectetur adipisicing<span style="background-color: #a05995;"></span></span>
</a>
</li>
<li>
<a href="#" class="" >
<img src="http://i.imgur.com/9dFFuH5.png">
<span>Mollitia harum<span style="background-color: #b38c51;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/7bQ73kd.png">
<span>veritatis ea ipsa<span style="background-color: #3d7d7d;"></span></span>
</a>
</li>
</ul>
https://jsfiddle.net/afelixj/79pybrh9/1/
Add max-width to the span
li span{
display: block;
max-width: 120px;
}
You need to add flex-wrap: wrap; on your <ul> to specify you want it to wrap its content.
how to center dropdown navbar, and make it still responsive?
i already try almost every method i found on this site, and internet, but still cant fix my problem, 1 method almost fix my problem but make my nav bar not responsive
body {
color: #ffffff;
background-color: #000000;
}
h1 {
color: white;
font-family: "orator std";
font-size: 44px;
letter-spacing: 0px;
line-height: 8px;
}
h2 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
line-height: 1px;
}
h3 {
color: white;
font-family: "orator std";
font-size: 14px;
letter-spacing: 1px;
margin-right: 100px;
margin-left: 100px;
}
h4 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
text-align: center;
}
h5 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
}
.thumbnail {
color: white;
background-color: #414141;
border-color: rgb(44, 44, 44);
}
.thumbnail .caption {
padding: 9px;
color: white;
margin-top: -14px;
}
.navbar-brand {
margin-top: 15px;
max-width: 30px;
padding: 0;
max-height: 30px;
}
.img-responsive {margin:0 auto;
}
.btn {
color: #ffffff;
text-align: center;
}
.btn:active {
color: red !important;
}
.btn:hover {
color: #8E8E8E;
}
.navbar {
border-radius: 0px;
border-width: 0px;
margin-top: 20%;
font-family: "Orator Std";
font-size: 18px;
color: #ffffff;
background-color: #000000;
vertical-align: center;
text-align: center;
margin-top: 0%;
}
.navbar li a {
color: #ffffff !important;
}
.navbar li a:hover {
color: gray !important;
}
.navbar-inner, .navbar .btn-navbar {
background: #ffffff
}
.navbar-inverse .navbar-nav>li>a {
border-bottom: white !important;
border-radius: 5px !important;
}
.dropdown-menu {
color: #ffffff;
background-color: #000000;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px 6px 6px 6px;
border-radius: 0px;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content:" ";
float: right;
width: 0px;
height: 0px;
border-color: transparent;
border-style: solid;
border-width: 5px 0px 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -5px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #ffffff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0px 6px 6px;
-moz-border-radius: 6px 0px 6px 6px;
border-radius: 6px 0px 6px 6px;
}
#media screen and (max-width: 768px) {
.navbar .navbar-collapse a {
text-align: left;
padding-left: 43%;
}
.dropdown-submenu a {
padding-left: 44%;
}
.navbar .navbar-collapse .dropdown .dropdown-menu a {
padding-left: 45%;
}
}
#the-slider img{
width: 100%;
padding-left: 10%;
padding-right: 10%;
padding-top: 10%;
}
.navbar-nav li{
position: relative
}
.navbar-nav li:not(:last-child):after{
content: '';
position: absolute;
right: 0px;
width: 1px;
height: 50%;
top: 20%;
background: white;
}
.dropdown-menu li:not(:last-child):after{
content: '';
position: absolute;
right: 0px;
width: 0px;
height: 50%;
top: 20%;
background: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<nav role="navigation" class="navbar navbar-inverse"> <!-- start navigation button -->
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="images/logonav1.png">
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-center">
<li class="#"><B><I>Home</B></I>
</li>
<li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#"><B><I>Collection </B></I><b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li><i class="fa fa-envelope-o fa-fw"></i><B><I>All Collection Portfolio</B></I>
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i>Collection 1
</li>
<li><i class="fa fa-pencil-square-o fa-fw"></i>Collection 2
</li>
<li><i class="fa fa-paper-plane-o fa-fw"></i>Collection 3
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i>Cita Tenun Indonesia
</li>
</ul>
</li>
<li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#">Things <b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li><i class="fa fa-envelope-o fa-fw"></i> Inbox
</li>
<li><i class="fa fa-pencil-square-o fa-fw"></i> Drafts
</li>
<li><i class="fa fa-paper-plane-o fa-fw"></i> Sent Items
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i> Trash
<li class="dropdown-submenu"> <a tabindex="-1" href="#"><i class="fa fa-hand-o-right fa-fw"></i> Profile</a>
<ul class="dropdown-menu">
<li><i class="fa fa-calendar-o fa-fw"></i> Account
</li>
<li><i class="fa fa-folder-open-o fa-fw"></i> Users
</li>
<li><i class="fa fa-file-o fa-fw"></i> Login
</li>
</ul>
</li>
</li>
</ul>
<li>About
</li>
<li>Contact us
</li>
</li>
</ul>
</ul>
</div>
</nav> <!-- end navigation button-->
<!-- javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>
The problem is that Boostrap sets the navbar-nav and navbar-nav li elements to float: left;, so it forces both to align left.
You'd need to override the Bootstrap styles for the min-width: 768px media query by setting the float property to none !important on those selectors, and add display: inline-block !important; to the navbar-nav element.
You need to use the media query in order to apply the changes only when the viewport is 768px or bigger.
The CSS rules you need to add to your stylesheet should look like this:
#media (min-width: 768px) {
.navbar-nav > li {
float: none !important;
display: inline-block !important;
}
.navbar-nav {
float: none !important;
}
}
And applied to the HTML:
body {
color: #ffffff;
background-color: #000000;
}
h1 {
color: white;
font-family: "orator std";
font-size: 44px;
letter-spacing: 0px;
line-height: 8px;
}
h2 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
line-height: 1px;
}
h3 {
color: white;
font-family: "orator std";
font-size: 14px;
letter-spacing: 1px;
margin-right: 100px;
margin-left: 100px;
}
h4 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
text-align: center;
}
h5 {
color: white;
font-family: "orator std";
font-size: 19px;
letter-spacing: 0px;
}
.thumbnail {
color: white;
background-color: #414141;
border-color: rgb(44, 44, 44);
}
.thumbnail .caption {
padding: 9px;
color: white;
margin-top: -14px;
}
.navbar-brand {
margin-top: 15px;
max-width: 30px;
padding: 0;
max-height: 30px;
}
.img-responsive {
margin: 0 auto;
}
.btn {
color: #ffffff;
text-align: center;
}
.btn:active {
color: red !important;
}
.btn:hover {
color: #8E8E8E;
}
.navbar {
border-radius: 0px;
border-width: 0px;
margin-top: 20%;
font-family: "Orator Std";
font-size: 18px;
color: #ffffff;
background-color: #000000;
vertical-align: center;
text-align: center;
margin-top: 0%;
}
.navbar li a {
color: #ffffff !important;
}
.navbar li a:hover {
color: gray !important;
}
.navbar-inner,
.navbar .btn-navbar {
background: #ffffff
}
.navbar-inverse .navbar-nav>li>a {
border-bottom: white !important;
border-radius: 5px !important;
}
.dropdown-menu {
color: #ffffff;
background-color: #000000;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px 6px 6px 6px;
border-radius: 0px;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0px;
height: 0px;
border-color: transparent;
border-style: solid;
border-width: 5px 0px 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -5px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #ffffff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0px 6px 6px;
-moz-border-radius: 6px 0px 6px 6px;
border-radius: 6px 0px 6px 6px;
}
#media screen and (max-width: 768px) {
.navbar .navbar-collapse a {
text-align: left;
padding-left: 43%;
}
.dropdown-submenu a {
padding-left: 44%;
}
.navbar .navbar-collapse .dropdown .dropdown-menu a {
padding-left: 45%;
}
}
#the-slider img {
width: 100%;
padding-left: 10%;
padding-right: 10%;
padding-top: 10%;
}
.navbar-nav li {
position: relative
}
.navbar-nav li:not(:last-child):after {
content: '';
position: absolute;
right: 0px;
width: 1px;
height: 50%;
top: 20%;
background: white;
}
.dropdown-menu li:not(:last-child):after {
content: '';
position: absolute;
right: 0px;
width: 0px;
height: 50%;
top: 20%;
background: red;
}
#media (min-width: 768px) {
.navbar-nav > li {
float: none !important;
display: inline-block !important;
}
.navbar-nav {
float: none !important;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<nav role="navigation" class="navbar navbar-inverse">
<!-- start navigation button -->
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.html" class="pull-left">
<img src="images/logonav1.png">
</a>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-center">
<li class="#"><B><I>Home</B></I>
</li>
<li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#"><B><I>Collection </B></I><b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li><i class="fa fa-envelope-o fa-fw"></i><B><I>All Collection Portfolio</B></I>
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i>Collection 1
</li>
<li><i class="fa fa-pencil-square-o fa-fw"></i>Collection 2
</li>
<li><i class="fa fa-paper-plane-o fa-fw"></i>Collection 3
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i>Cita Tenun Indonesia
</li>
</ul>
</li>
<li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#">Things <b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li><i class="fa fa-envelope-o fa-fw"></i> Inbox
</li>
<li><i class="fa fa-pencil-square-o fa-fw"></i> Drafts
</li>
<li><i class="fa fa-paper-plane-o fa-fw"></i> Sent Items
</li>
<li class="divider"></li>
<li><i class="fa fa-trash-o fa-fw"></i> Trash
<li class="dropdown-submenu"> <a tabindex="-1" href="#"><i class="fa fa-hand-o-right fa-fw"></i> Profile</a>
<ul class="dropdown-menu">
<li><i class="fa fa-calendar-o fa-fw"></i> Account
</li>
<li><i class="fa fa-folder-open-o fa-fw"></i> Users
</li>
<li><i class="fa fa-file-o fa-fw"></i> Login
</li>
</ul>
</li>
</li>
</ul>
<li>About
</li>
<li>Contact us
</li>
</li>
</ul>
</ul>
</div>
</nav>
<!-- end navigation button-->
<!-- javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>