I have coded a Bootstrap 3 dropdown menu in the static site proof. The client wants sub-menus and I have that working. I have made the menus in Wordpress but now the sub-menus are not working. Here is the html:
<!-- Main navbar ================================================== -->
<!-- <div class="row"> -->
<nav class="navbar navbar-default main-navbar" role="navigation">
<div class="container">
<div class="navbar-header main-nav">
<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>
</div><!-- .navbar-header -->
<div id="navbar"class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
Who We Are<span class="caret"></span>
<ul class="dropdown-menu">
<li>Our Story</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Our Team</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Staff</li>
<li>Board Members</li>
</li>
</ul>
</li>
<li>FAQ</li>
</ul>
</li>
<li class="dropdown">
Sports<span class="caret"></span>
<ul class="dropdown-menu">
<li>Olympic</li>
<li>Paralympic</li>
</ul>
</li>
<li class="dropdown">
Athletes and Coaches<span class="caret"></span>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Athletes</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Current</li>
<li>Alumni</li>
<li>NEXTGEN</li>
<li>Up and Coming</li>
</li>
</ul>
</li>
<li>Coaches</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Training Groups</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Curling</li>
<li>Diving</li>
<li>Senior Women's Volleyball</li>
<li>Senior Women's Wheelchair Basketball</li>
<li>Wesmen Wrestling</li>
</li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
Partnerships<span class="caret"></span>
<ul class="dropdown-menu">
<li>Sport Canada</li>
<li>Own the Podium</li>
<li>Sport Manitoba</li>
<li>COPSIN</li>
<li>Coaching Association of Canada</li>
<li>National Coaching Institute</li>
<li>Corporate Community</li>
</ul>
</li>
<li class="dropdown">
Service Delivery<span class="caret"></span>
<ul class="dropdown-menu">
<li>IST</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Sport Science</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Sport Dietetics</li>
<li>Sport Psychology</li>
<li>Physiology</li>
<li>Strength and Conditioning</li>
</li>
</ul>
</li>
<li>Sport Medicine</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Life Services</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Game Plan</li>
</li>
</ul>
</li>
<li>Elegibility</li>
</ul>
</li>
<li class="dropdown">
What’s Happening<span class="caret"></span>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Calendar of Events</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>External</li>
<li>CSCM</li>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">In The News</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>Latest News</li>
<li>Press Releases</li>
<li>Archive</li>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Community Involvement</a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<li>IMPACT Camps</li>
<li>Sports and Arts Program</li>
</li>
</ul>
</li>
<li>Event Sign-up & Registration</li>
</ul>
</li>
</ul>
</div><!--/.collapse navbar-collapse -->
</div><!-- container -->
</div>
</nav><!-- .navbar navbar-default main-nav -->
The CSS is:
#header {
z-index: 99999;
}
#navbar {
padding-left: 25px;
padding-right: 0px;
}
.navbar {
margin-bottom: 0px;
}
.navbar-default .navbar-nav > li > a {
font-family: $sans-serif;
font-size: 1em;
color:$text-color;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 23px;
border-radius: 0px;
}
.container-fluid {
margin-left: auto;
margin-right: auto;
}
.nav > li {
padding-left: 10px;
}
.navbar-wrapper {
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 20;
}
.navbar-default {
border: none;
border-radius: 0px;
background: #d1d1d1;
}
.main-nav {
height: 40px;
background: #d1d1d1;
text-align: center;
border-radius: 0px;
}
.main-nav li a {
font-family: $sans-serif;
font-size: 1em;
color:$text-color;
padding-left: 15px;
padding-right: 15px;
}
.main-nav .nav {
float: none;
}
.main-nav .nav > li {
display: inline-block;
float: none;
/* margin: 0 5px;*/
vertical-align: middle;
}
/*.main-nav .nav li a {
color:$text-color;
width: 100%;
}*/
.main-nav .nav li a:hover {
color: #a31c27;
}
.main-nav .nav a {
width:100%;
height:auto;
vertical-align:middle;
display:inline-block;
}
.navbar-nav > li > .dropdown-menu {
background: #d1d1d1;
color: $reversed-color;
}
.navbar-wrapper > .container {
padding-right: 0;
padding-left: 0;
}
.navbar-wrapper .navbar {
padding-right: 15px;
padding-left: 15px;
}
.navbar-wrapper .navbar .container {
width: auto;
}
.dropdown-menu > li > a {
font-family: $sans-serif;
line-height: 2em;
}
.dropdown-submenu > li > a:focus,
.dropdown-submenu > li > a:hover {
color: #262626;
text-decoration: none;
background-color: #F5F5F5;
}
.dropdown-submenu {
position:relative;
padding-right: 15px;
}
.dropdown-submenu > .dropdown-menu {
top:0;left:100%;
margin-top:-6px;
margin-left:-1px;
-webkit-border-radius:0 6px 6px 6px;
-moz-border-radius:0 6px 6px 6px;
border-radius:0 6px 6px 6px;
background-color: #d1d1d1;
}
.dropdown-submenu:hover>.dropdown-menu {
display:block;
background: #d1d1d1;
}
.dropdown-submenu>a:after {
display:block;content:" ";
float:right;
width:0;
height:0;
border-color:transparent;
border-style:solid;
border-width:5px 0 5px 5px;
border-left-color: $text-color;
margin-top:5px;
margin-right:-12px;
}
.navbar-default .navbar-nav > li > a:hover {
color: $primaryColor;
background-color: $background;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border-color: none;
}
.dropdown-backdrop {
position: static;
}
.dropdown-menu li:hover > .dropdown-menu {
visibility: visible;
display: block;
top: 0px;
left: 100%;
}
.dropdown-menu a:after {
display:block;content:" ";
float:right;
width:0;
height:0;
border-color:transparent;
border-style:solid;
border-width:5px 0 5px 5px;
border-left-color: $text-color;
margin-top:5px;
margin-right:-12px;
}
If someone can give me a hand that would be great.
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 am developing an app using angular;my problem is i have to create a structure like in the uploaded picture,but i can't figure it out;
i have tried with list style and pseudo classes,but it does n't work it out;
.mod-ul li::before {
content: "L";
color: #88c4e6;
position: relative;
left: 0;
top: -4px;
font-size: 25px;
}
You could do something like the below:
ul,
li {
list-style: none;
margin: 0;
padding: 0;
}
ul {
padding-left: 1em;
}
ul ul li {
padding-left: 1em;
border: 1px solid black;
border-width: 0 0 1px 1px;
}
li.container {
border-bottom: 0px;
}
li.empty {
font-style: italic;
color: silver;
border-color: silver;
}
li p {
margin: 0;
background: white;
position: relative;
top: 0.5em;
}
ul ul li ul {
border-top: 1px solid black;
margin-left: -1em;
padding-left: 2em;
}
ul ul li:last-child ul {
border-left: 1px solid white;
margin-left: -17px;
}
<ul class="parent">
<li class="container">
<p>Testing </p>
<ul>
<li>
<p>Testing 1</p>
</li>
<li>
<p>Testing 2</p>
</li>
<li class="container">
<p>Testing </p>
<ul>
<li>
<p>Testing 1</p>
</li>
<li>
<p>Testing 2</p>
</li>
<li>
<p>Testing 3</p>
</li>
</ul>
</li>
</ul>
</li>
<li class="container">
<p>Testing </p>
<ul>
<li>
<p>Testing 1</p>
</li>
<li>
<p>Testing 2</p>
</li>
<li>
<p>Testing 3</p>
</li>
</ul>
</li>
<li class="container">
<p>Testing </p>
<ul>
<li class="empty">
<p>empty</p>
</li>
</ul>
</li>
</ul>
FRONT END FOR NAVBAR
<nav class="navbar navbar-default" role="navigation" style="background-color: #FFFFFF">
<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">
<asp:ImageButton ID="imglogo" runat="server" ImageUrl="~/Images/logo 1 copy 4-1.jpg" AlternateText="LOGO" CausesValidation="False" OnClick="imgblogo_Click" PostBackUrl="~/Home.aspx" CssClass="img img-responsive logo" />
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<h4>CATEGORY<b class="caret"></b></h4>
</a>
<ui>...........</ui>
</li>
<li>
<a href="#">
<h4>SHIRT</h4>
</a>
</li>
<li>
<a href="#">
<h4>PANTS</h4>
</a>
</li>
<li>
<a href="#">
<h4>SHOE</h4>
</a>
</li>
<li>
<a href="#">
<h4>FASHION</h4>
</a>
</li>
<li>
<a href="#">
<h4>PAPER QULING</h4>
</a>
</li>
<li>
<a href="#">
<h4>TERRACOTA</h4>
</a>
</li>
<li>
<a href="#">
<h4>MEENAKARI</h4>
</a>
</li>
<li>
<a href="#">
<h4>TRADITIONAL</h4>
</a>
</li>
<li>
<a></a>
</li>
</ul>
</ul>
</div>
<br />
</nav>
When i decrease size of google chrome the category and other stuff overlaps logo at width:1502px
I have tried this css
#media (max-width:1502px){
.navbar-brand {
height: 80px;
}
.navbar {
background-color: #ccc;
}
.navbar-toggle {
margin-top: 25px;
}
}
IMAGE : IMAGE OF NAVBAR
Because you have so many links inside your nav and due to the increased font size it's overflowing since there simply is not enough space the smaller the viewport gets.
You can change the breakpoint that the navbar collapses, additionally you can change the display property of the links so they wrap. This will leave them exposed longer but you'll still need to collapse the nav earlier then normal.
Example I:
.navbar.navbar-tall {
background-color: white;
}
.navbar.navbar-tall .navbar-nav > li > a {
text-transform: uppercase;
font-size: 20px;
font-weight: bold;
}
.navbar.navbar-tall .navbar-brand {
padding-top: 5px;
}
.navbar.navbar-tall .navbar-brand img {
height: 90px;
}
#media (min-width: 1505px) {
.navbar.navbar-tall .navbar-nav > li > a {
line-height: 70px;
}
}
/*CSS TO CHANGE COLLAPSE BREAKPOINT STARTS HERE*/
#media (max-width: 1504px) 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: 1504px) {
.navbar .navbar-header {
float: none;
min-height: 100px;
}
.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: 32.5px;
}
.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 rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<nav class="navbar navbar-default navbar-tall" 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="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">
<img src="http://wallpapercave.com/wp/Tk48wK7.png" alt="Brand Name">
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
CATEGORY <span class="caret"></span>
<ul class="dropdown-menu">
<li>LINK
</li>
</ul>
</li>
<li>
SHIRT
</li>
<li>
PANTS
</li>
<li>
SHOE
</li>
<li>
FASHION
</li>
<li>
PAPER QULING
</li>
<li>
TERRACOTA
</li>
<li>
MEENAKARI
</li>
<li>
TRADITIONAL
</li>
</ul>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Example II: Wrapped Links
.navbar.navbar-tall {
background-color: white;
}
.navbar.navbar-tall .navbar-nav > li > a {
text-transform: uppercase;
font-size: 20px;
font-weight: bold;
}
.navbar.navbar-tall .navbar-brand {
padding-top: 5px;
}
.navbar.navbar-tall .navbar-brand img {
height: 90px;
}
#media (min-width: 1500px) {
.navbar.navbar-tall .navbar-nav > li > a {
line-height: 70px;
}
}
#media (max-width: 1499px) and (min-width: 1000px) {
.navbar.navbar-tall .navbar-nav {
display: table;
float: none;
}
.navbar.navbar-tall .navbar-nav > li {
display: table-cell;
}
}
/*CSS TO CHANGE COLLAPSE BREAKPOINT STARTS HERE*/
#media (max-width: 1499px) and (min-width: 1000px) {
.navbar.navbar-fixed-bottom .navbar-collapse,
.navbar.navbar-fixed-top .navbar-collapse {
max-height: auto;
overflow-x: visible;
}
}
#media (max-width: 999px) {
.navbar .navbar-header {
float: none;
min-height: 100px;
}
.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: 32.5px;
}
.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 rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<nav class="navbar navbar-default navbar-tall" 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="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">
<img src="http://wallpapercave.com/wp/Tk48wK7.png" alt="Brand Name">
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
CATEGORY <span class="caret"></span>
<ul class="dropdown-menu">
<li>LINK
</li>
</ul>
</li>
<li>
SHIRT
</li>
<li>
PANTS
</li>
<li>
SHOE
</li>
<li>
FASHION
</li>
<li>
PAPER QULING
</li>
<li>
TERRACOTA
</li>
<li>
MEENAKARI
</li>
<li>
TRADITIONAL
</li>
</ul>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Maybe this is what you are looking for:
.navbar-brand {
padding: 0px !important;
}
.navbar-brand > img {
height: 100%;
width: auto;
}
#media (min-width:768px) {
.navbar-brand {
padding: 15px 0px 0px 0px !important;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default" role="navigation" style="background-color: #FFFFFF">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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">
<!--start - only for test pupose-->
<img alt="Brand" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTAUTCWRBOD3bLFlPjl_MsOm3-E8X0P3prqoSNRr6B_jJluRyiy" class="img img-responsive logo">
<!--start - only for test pupose-->
<asp:ImageButton ID="imglogo" runat="server" ImageUrl="~/Images/logo 1 copy 4-1.jpg" AlternateText="LOGO" CausesValidation="False" OnClick="imgblogo_Click" PostBackUrl="~/Home.aspx" CssClass="img img-responsive logo" />
</a>
</div>
<div class="navbar-collapse collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<h4>CATEGORY<b class="caret"></b></h4>
</a>
</li>
<li>
<a href="#">
<h4>SHIRT</h4>
</a>
</li>
<li>
<a href="#">
<h4>PANTS</h4>
</a>
</li>
<li>
<a href="#">
<h4>SHOE</h4>
</a>
</li>
<li>
<a href="#">
<h4>FASHION</h4>
</a>
</li>
<li>
<a href="#">
<h4>PAPER QULING</h4>
</a>
</li>
<li>
<a href="#">
<h4>TERRACOTA</h4>
</a>
</li>
<li>
<a href="#">
<h4>MEENAKARI</h4>
</a>
</li>
<li>
<a href="#">
<h4>TRADITIONAL</h4>
</a>
</li>
<li><a></a></li>
</ul>
</div>
</div>
</nav>
Good day everyone!
I got a simple menu,and i am trying to make a hover arrow for each item
the way it should look:
sample image. I have got this code already
thanks for any advice!
.mainmenu{
display: inline-block;
list-style-type: none;
padding-top: 25px;
padding-left: 0px;
}
.mainmenu_item{
display: inline;
padding-right:8px;
}
.mainmenu_link{
font-family:FrutigerCELight,Arial,Helvetica,sans-serif;
text-decoration: none;
font-size:14px;
color:black;
}
<ul class="mainmenu">
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Home">Home</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="About Us">About Us</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Services">Services</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Portfolio">Portfolio</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Blog">Blog</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Contact">Contact</a>
</li>
</ul>
If you want to add pseudo element on hover first you need to target :hover and then add pseudo element. Your selector will be .mainmenu_item:hover:after
.mainmenu{
display: inline-block;
list-style-type: none;
padding-top: 25px;
padding-left: 0px;
font-size:0;
}
.mainmenu_item{
font-size: 14px;
display: inline-block;
padding:8px;
position: relative;
line-height:2em;
background: #000;
color: #FFF;
}
.mainmenu_item a {
text-decoration: none;
color: currentColor;
}
.mainmenu_item:hover:after {
content:'';
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid currentColor;
position: absolute;
bottom:0;
left:50%;
margin-left: -5px;
}
.mainmenu_link{
font-family:FrutigerCELight,Arial,Helvetica,sans-serif;
text-decoration: none;
font-size:14px;
}
<ul class="mainmenu">
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Home">Home</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="About Us">About Us</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Services">Services</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Portfolio">Portfolio</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Blog">Blog</a>
</li>
<li class="mainmenu_item"><a class="mainmenu_link" href="#" title="Contact">Contact</a>
</li>
</ul>
Add <span class="arrow-up"></span> after every a tag.
then add css:
.mainmenu_item:hover .arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid white;
position: absolute;
top:33px;
left:40%;
}
Try it your self https://jsfiddle.net/5fbuLh7g/
Today I was trying to learn how to create those triangles with CSS Borders and I finally did. Awesome stuff! Although it seems that whenever I hover over the menu two things happen that I want to fix (1) the menu seems to snap and resize on hover and resize back on mouse out. (2) the hover opacity seems to flow down to the first item of the sub-menu. I've created a JSFiddle over here. If anyone can drop some knowledge on me, I'd be very grateful!
HTMLCode
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
</head>
<body>
<div class="navContainer">
<ul class="nav group">
<li>
<a class="active" href="#">Home</a>
<ul class="subNav group">
<li>Sub-Item</li>
<li>Sub-Item</li>
<li>Sub-Item</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Safari</a>
<ul class="subNav group">
<li>Sub-Item</li>
<li>Sub-Item</li>
<li>Sub-Item</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Prices</a>
<ul class="subNav group">
<li>Sub-Item</li>
<li>Sub-Item</li>
<li>Sub-Item</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Photos</a>
<ul class="subNav group">
<li>Sub-Item</li>
<li>Sub-Item</li>
<li>Sub-Item</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Contact</a>
<ul class="subNav group">
<li>Sub-Item</li>
<li>Sub-Item</li>
<li>Sub-Item</li>
</ul>
</li>
</ul>
</div>
<div class="box"></div>
</body>
</html>
CSS Code
html {
font-size: 62.5%;
}
body {
background: #fff;
font-size: 1.6em;
}
.navContainer {
width: 1100px;
margin: 0 auto;
}
ul.nav {
margin: 0;
padding: 0;
position: relative;
left:30%;
font-size: 1.3rem;
}
li {
float: left;
list-style-type:none;
text-align: center;
background: #aa2929;
}
li a {
display: block;
text-decoration: none;
color: #fff;
color: rgba(255,255,255, 0.7);
text-shadow: 0 1px 1px rgba(0,0,0,0.5);
padding: 1rem 2rem;
transition: all .3s ease-in-out;
}
li a:focus,
li a:hover {
color: #fff;
background: #a85555;
background: rgba(255,255,255, 0.15);
}
ul.subNav {
margin: 0;
padding: 0;
}
ul.subNav li {
float: none;
display: none;
}
.nav li:hover ul.subNav li {
display: block;
}
.group:after {
content: "";
display: table;
clear: both;
}
li a.active:hover:after {
content: "";
box-sizing: border-box;
display: block;
margin: 0 auto;
padding: 0;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid rgba(89, 172, 255, 0.83);
}
It's because your "Sub-Items" are wider than your main nav elements, so when you hover and the Sub-Items are shown, the parent (main nav element) has to expand to fit it.
Putting a fixed width on .nav.group > li should solve your problem.
Another option is to absolute-position the dropdowns.
position absolute on your subNav and a fixed width on the parent list items ( .nav li) will fix the issue
.nav li{
width:80px; /* I used 80px as example */
}
.subNav{
position:absolute;
}
Add the above to the base of your css it will fix it.
Code Snippet...
html {
font-size: 62.5%;
}
body {
background: #fff;
font-size: 1.6em;
}
.navContainer {
width: 1100px;
margin: 0 auto;
}
ul.nav {
margin: 0;
padding: 0;
font-size: 1.3rem;
}
li {
float: left;
list-style-type: none;
text-align: center;
background: #aa2929;
}
li a {
display: block;
text-decoration: none;
color: #fff;
color: rgba(255, 255, 255, 0.7);
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
padding: 1rem 2rem;
transition: all .3s ease-in-out;
}
li a:focus,
li a:hover {
color: #fff;
background: #a85555;
background: rgba(255, 255, 255, 0.15);
}
ul.subNav {
margin: 0;
padding: 0;
}
ul.subNav li {
float: none;
display: none;
}
.nav li:hover ul.subNav li {
display: block;
}
.group:after {
content: "";
display: table;
clear: both;
}
li a.active:hover:after {
content: "";
box-sizing: border-box;
display: block;
margin: 0 auto;
padding: 0;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid rgba(89, 172, 255, 0.83);
}
.nav li {
width: 80px;
}
.subNav {
position: absolute;
}
.nav > li > a {
height: 1.5em;
}
<body>
<div class="navContainer">
<ul class="nav group">
<li>
<a class="active" href="#">Home</a>
<ul class="subNav group">
<li>Sub-Item
</li>
<li>Sub-Item
</li>
<li>Sub-Item
</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Safari</a>
<ul class="subNav group">
<li>Sub-Item
</li>
<li>Sub-Item
</li>
<li>Sub-Item
</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Prices</a>
<ul class="subNav group">
<li>Sub-Item
</li>
<li>Sub-Item
</li>
<li>Sub-Item
</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Photos</a>
<ul class="subNav group">
<li>Sub-Item
</li>
<li>Sub-Item
</li>
<li>Sub-Item
</li>
</ul>
</li>
<li class="active">
<a class="active" href="#">Contact</a>
<ul class="subNav group">
<li>Sub-Item
</li>
<li>Sub-Item
</li>
<li>Sub-Item
</li>
</ul>
</li>
</ul>
</div>
Hope this helps