Bootstrap 4 third level child menu not on the right side - css

I'm using the following Bootstrap 4 theme in Wordpress: https://cutt.ly/QfzDnKv
I'm using the Bootstrap 4 navbar with third level child menu's which is not by Bootstrap 4 defaults supported. That's why I used this custom CSS in Bootstrap 4:
https://www.codeply.com/go/ji5ijk6yJ4
.navbar-nav li:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position:relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top:-6px;
}
/* rotate caret on hover */
.dropdown-menu > li > a:hover:after {
text-decoration: underline;
transform: rotate(-90deg);
}
I have now a situation that my child menu's will be shown up on the bottom of each parent menu:
In the example above Exact needs to show up on the right side of the parent menu (like the codeply example). Could anyone tell me what I have to adjust in order to let it show up the correct way? I'm struggling already 1 week with this.
Thanks!
grid

Try this code.
.navbar-nav li:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position:relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top:-6px;
}
/* rotate caret on hover */
.dropdown-menu > li > a:hover:after {
text-decoration: underline;
transform: rotate(-90deg);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown </a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" href="http://google.com">Google</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Submenu</a></li>
<li><a class="dropdown-item" href="#">Submenu0</a></li>
<li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" href="#">Submenu 1</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Subsubmenu1</a></li>
<li><a class="dropdown-item" href="#">Subsubmenu1</a></li>
</ul>
</li>
<li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" href="#">Submenu 2</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Subsubmenu2</a></li>
<li><a class="dropdown-item" href="#">Subsubmenu2</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>

I fixed this actually by using the answer of Bhautik. I tried his code line by line and came to the conclusion that the following CSS could be used:
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top:-6px;
}
Thanks,
Have a nice day.

Related

Prevent NavBar from Expanding When Using Z-Index

I posted a previous question concerning Positioning NavBar at Top of Page but Losing Clickability on Main Content. The question was answered but it has now led to an unintended consequence. At first it prevented a dropdown menu item from appearing above the content. I updated the dropdown with a z-index: 99999; position: relative; value to get it to display above the content but now it expands the height of the Header section. Here are 3 images.
Unselected Dropdown:
How it used to appear:
How it now appears using z-index: 99999;position: relative;
Here is the code for the navbar:
<header>
<div class="navbar navbar-inverse" id="edadTopNavigation">
<div class="container-fluid app-navbar">
<div class="navbar-collapse collapse app-navbar-text-section">
<ul class="nav navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="adminDropdownMenuLink" href='#' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="fa fa-cog"></div> Admin</a>
<div class="dropdown-menu" aria-labelledby="adminDropdownMenuLink">
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="Acronym" asp-action="Index">Acronyms</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">Users</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">States</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">Countries</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</header>
Here is the current CSS:
.navbar {
/* margin-bottom: 0px;*/
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%;
overflow: hidden;
z-index: 200
}
.dropdown-menu {
padding: 10px;
background-color: #fff;
background-color: #fffff2;
z-index: 99999;
position: relative;
}
What can I do to get the dropdown to display like image 2 instead of image 3?

Bootstrap 4 nav-link hover effect

I'm trying to put a hover effect targeting the a-links in the navigation bar only (not the forwardslashes).
But I can't seem to access only the a-links, the effect ends up running along the whole navbar instead.
Seems to be a conflict with Bootstrap 4 here.
HTML
<nav class="navbar sticky-top navbar-expand-md navbar-light bg-light">
<!-- <div class="mx-auto d-sm-flex d-block flex-sm-nowrap"> -->
<a class="navbar-brand" href="https://www.facebook.com/GetMove.Official/">GET MOVE</a>
<button
class="navbar-toggler mr-left custom-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home<span> / </span><span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#past-bookings">Archive<span> / </span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About<span> / </span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#subscribe">Newsletter<span> / </span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="mailto: hola#getmove.net">Contact</a>
</li>
</ul>
<ul class="nav navbar-nav flex-row justify-content-center flex-nowrap">
<li class="nav-item">
<a
class="nav-link nav-social-icon"
target="_blank"
href="https://www.facebook.com/GetMove.Official/"
><i class="fab fa-facebook-square"></i
></a>
</li>
<li class="nav-item">
<a class="nav-link nav-social-icon" target="_blank" href="https://www.instagram.com/getmovemx/"
><i class="fab fa-instagram"></i
></a>
</li>
<li class="nav-item">
<a class="nav-link nav-social-icon" target="_blank" href="https://soundcloud.com/getmove"
><i class="fab fa-soundcloud"></i
></a>
</li>
</ul>
</div>
</nav>
CSS
.nav-item:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 0%;
border-bottom: 1px solid black;
transition: 0.4s;
}
.nav-item:hover:after {
width: 100%;
}
Fiddle here
https://codepen.io/pen/WNNPdxv
To solve this issue you should not put separators inside the anchor elements.
Below is an approach which eliminates the extra HTML using the content property.
This is similar to Bootstrap's breadcrumb.
But as you're already familiar, first some cleanup ^^
remove the span separators from nav-links
use the span for text nodes (could be handy to put the animation on there)
move the animation from :after to :before (a separator is logically after an element, except for the last-child perhaps, this also gives you the elements width where you can now control the right position.)
use the :after for the separator
provide full width for the main navigation and use flexbox to align the space it's using (flex-end, center, space-between, ...)
HTML changes
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="nav navbar-nav navbar-primary w-100 ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">
<span>Home</span>
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#past-bookings"><span>Archive</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><span>About</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#subscribe"><span>Newsletter</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="mailto: hola#getmove.net"><span>Contact</span></a>
</li>
</ul>
<ul class="nav navbar-nav navbar-secondary flex-row justify-content-center flex-nowrap">
<li class="nav-item">
<a class="nav-link nav-social-icon" target="_blank" href="https://www.facebook.com/GetMove.Official/"><i class="fa fa-facebook-square"></i></a>
</li>
<li class="nav-item">
<a class="nav-link nav-social-icon" target="_blank" href="https://www.instagram.com/getmovemx/"><i class="fa fa-instagram"></i></a>
</li>
<li class="nav-item">
<a class="nav-link nav-social-icon" target="_blank" href="https://soundcloud.com/getmove"><i class="fa fa-soundcloud"></i></a>
</li>
</ul>
</div>
Solution
Now to solve the issue, place the animation on before and separator on the after pseudo elements.
.navbar-primary .nav-item:after {
content: "/";
position: absolute;
top: 0.25rem;
left: auto;
right: -0.5rem; /* control the amount of space for the separator */
}
.navbar-primary .nav-item:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 0%;
border-bottom: 1px solid black;
transition: 0.4s;
}
.navbar-primary .nav-item:hover:before {
width: 100%;
}
In case you want to change the character, you have only one editing place.
DEMO
In case you want to change the animation without the padding I'd suggest to distract the nav-link padding using calc().
.navbar-primary .nav-link:before {
content: "";
position: absolute;
bottom: 0;
left: 0.5rem; /* nav-link padding-left */
width: 0%;
border-bottom: 1px solid black;
transition: 0.4s;
}
.navbar-primary .nav-link:hover:before {
width: calc(100% - 1rem); /* minus nav-link padding left and right */
}
DEMO
You should put the hover on the a-link, and then a-link position:relative, or put the class position-relative to the a-link.
.nav-item a {
position: relative;
}
.nav-item a:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 0%;
border-bottom: 1px solid black;
transition: 0.4s;
}
.nav-item a:hover:after {
width: 100%;
}

How to make on hover expand background color height on menu

The following is my code
<ul class="navbar-nav" style="margin-left: 16%;">
<li class="nav-item">
<!-- <button style="background-color: #009688; height: 25px;"> -->
<a class="nav-link" style="color: white; font-weight: 500;" href="home.php">Home</a>
<!-- </button> -->
</li>
<li class="nav-item">
<a class="nav-link" style="color: white; font-weight: 500;" href="about.php">About Us</a>
</li>
<li class="nav-item dropdown nav-mod">
<a class="nav-link dropdown-toggle" href="https://bootstrapthemes.co" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: white; font-weight: 500;">
Services
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="panchakarma.php">Panchakarma Therapies</a></li>
<li><a class="dropdown-item" href="ayurveda_medicines.php">Ayurveda Medicines</a></li>
<li><a class="dropdown-item" href="diet_consultation.php">Diet Consultation</a></li>
<li><a class="dropdown-item" href="meditation.php">Meditation</a></li>
<li><a class="dropdown-item" href="therapy_yoga.php">Therapy Yoga</a></li>
<li><a class="dropdown-item" href="physiotherapy.php">Physiotherapy</a></li>
<li><a class="dropdown-item" href="garbh_sanskar.php">Garbh Sanskar</a></li>
<li><a class="dropdown-item dropdown-toggle" href="#">Special Treatments</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="dhupana_chikista.php">Dhupana Chikista</a></li>
<li><a class="dropdown-item" href="kumkumadi_facial.php">Kumkumadi Facial</a></li>
<li><a class="dropdown-item" href="rejuvation_treatment.php">Rejuvation Treatment</a></li>
<li><a class="dropdown-item" href="relaxation_treatment.php">Relaxation Treatment</a></li>
<li><a class="dropdown-item" href="suvarna_prashan.php">Suvarna Prashan</a></li>
</ul>
</li>
<li><a class="dropdown-item" href="other_facility.php">Other Facilities we provide</a></li>
</ul>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" style="color: white; font-weight: 500;" href="online_consultation.php">Online Consultation</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" style="color: black; font-weight: bold;" href="packages.php">Packages</a>
</li> -->
<li class="nav-item nav-mod">
<a class="nav-link" style="color: white; font-weight: 500;" href="courses.php">Courses</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" style="color: black; font-weight: bold;" href="products.php">Products</a>
</li> -->
<li class="nav-item nav-mod">
<a class="nav-link" style="color: white; font-weight: 500;" href="career.php">Career</a>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" style="color: white; font-weight: 500;" href="contact_us.php">Contact Us</a>
</li>
</ul>
I want to make this on like as shown below in the image(Header)
enter image description here
If anyone knows about using CSS please let me help.
The following image shows from my website look.enter image description here
I want to make my header as shown in first image.
You can do it by using the same line-height for ul, li and a. While you will give the same height for ul, li and a, then it will display the hover height like the menu item height.
nav.navbar.navbar-default {
background: #288a90;
}
ul.nav.navbar-nav {
background: #288a90;
}
.navbar,
.navbar ul {
line-height: 65px;
}
.navbar ul li a {
line-height: 65px;
color: white !important;
font-weight: 500;
}
.navbar ul li a:hover {
line-height: 65px;
background-color: #fff !important;
color: #288a90 !important;
}
.dropdown-menu {
background-color: #288a90 !important;
padding: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<ul class="nav navbar-nav" style="margin-left: 16%;">
<li class="nav-item">
<a class="nav-link" href="home.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">About Us</a>
</li>
<li class="nav-item dropdown nav-mod">
<a class="nav-link dropdown-toggle" href="https://bootstrapthemes.co" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: white; font-weight: 500;">
Services
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="panchakarma.php">Panchakarma Therapies</a></li>
<li><a class="dropdown-item" href="ayurveda_medicines.php">Ayurveda Medicines</a></li>
<li><a class="dropdown-item" href="diet_consultation.php">Diet Consultation</a></li>
<li><a class="dropdown-item" href="meditation.php">Meditation</a></li>
<li><a class="dropdown-item" href="therapy_yoga.php">Therapy Yoga</a></li>
<li><a class="dropdown-item" href="physiotherapy.php">Physiotherapy</a></li>
<li><a class="dropdown-item" href="garbh_sanskar.php">Garbh Sanskar</a></li>
<li><a class="dropdown-item dropdown-toggle" href="#">Special Treatments</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="dhupana_chikista.php">Dhupana Chikista</a></li>
<li><a class="dropdown-item" href="kumkumadi_facial.php">Kumkumadi Facial</a></li>
<li><a class="dropdown-item" href="rejuvation_treatment.php">Rejuvation Treatment</a></li>
<li><a class="dropdown-item" href="relaxation_treatment.php">Relaxation Treatment</a></li>
<li><a class="dropdown-item" href="suvarna_prashan.php">Suvarna Prashan</a></li>
</ul>
</li>
<li><a class="dropdown-item" href="other_facility.php">Other Facilities we provide</a></li>
</ul>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" href="career.php">Career</a>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" href="contact_us.php">Contact Us</a>
</li>
</ul>
</nav>
</body>
</html>
you're just putting the background on the anchor (a) tag right?
you probably need to put in the li tag, but i'm not sure, if it dont work please edit your question and put the css file too or use the codepen
I have done some changes, some unnecessary css and made css according to bootstrap to make sure when you add your css file (after bootstrap css file) you don't have to use !important
nav.navbar.navbar-default {
background: #288a90;
}
ul.nav.navbar-nav {
background: #288a90;
}
.navbar-default .navbar-nav>li>a {
line-height: 65px;
color: #fff !important;
font-weight: 500;
}
.navbar-default .navbar-nav>li>a:hover {
background-color: #fff !important;
color: #288a90 !important;
}
.dropdown-menu {
background-color: #288a90 !important;
padding: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<ul class="nav navbar-nav" style="margin-left: 16%;">
<li class="nav-item">
<a class="nav-link" href="home.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">About Us</a>
</li>
<li class="nav-item dropdown nav-mod">
<a class="nav-link dropdown-toggle" href="https://bootstrapthemes.co" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: white; font-weight: 500;">
Services
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="panchakarma.php">Panchakarma Therapies</a></li>
<li><a class="dropdown-item" href="ayurveda_medicines.php">Ayurveda Medicines</a></li>
<li><a class="dropdown-item" href="diet_consultation.php">Diet Consultation</a></li>
<li><a class="dropdown-item" href="meditation.php">Meditation</a></li>
<li><a class="dropdown-item" href="therapy_yoga.php">Therapy Yoga</a></li>
<li><a class="dropdown-item" href="physiotherapy.php">Physiotherapy</a></li>
<li><a class="dropdown-item" href="garbh_sanskar.php">Garbh Sanskar</a></li>
<li><a class="dropdown-item dropdown-toggle" href="#">Special Treatments</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="dhupana_chikista.php">Dhupana Chikista</a></li>
<li><a class="dropdown-item" href="kumkumadi_facial.php">Kumkumadi Facial</a></li>
<li><a class="dropdown-item" href="rejuvation_treatment.php">Rejuvation Treatment</a></li>
<li><a class="dropdown-item" href="relaxation_treatment.php">Relaxation Treatment</a></li>
<li><a class="dropdown-item" href="suvarna_prashan.php">Suvarna Prashan</a></li>
</ul>
</li>
<li><a class="dropdown-item" href="other_facility.php">Other Facilities we provide</a></li>
</ul>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" href="career.php">Career</a>
</li>
<li class="nav-item nav-mod">
<a class="nav-link" href="contact_us.php">Contact Us</a>
</li>
</ul>
</nav>
</body>
</html>

Multi-Level NavBar in Angular 6 Bootstrap 4

(UPDATE: Resolved - i had to add the javascript in $(document).ready(function(), which i was missing. The below eg worked perfect for me.)
I am trying to make a Multi-Level Navbar work with Angular 6 & Bootstrap 4.
How do i expand and colapse sub-menu's on click or hover? I want the menu to expand to the right...
Eg: I found a solution on this link - but i am not sure how to inject Javascript in a Angular component.
https://codepen.io/surjithctly/pen/PJqKzQ
Here are my version details
+-- bootstrap#4.1.3
+-- jquery#3.3.1
+-- popper.js#1.14.4
Below is my Navbar Code
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#" style="color: red;">
My NAVBAR
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item">
<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="navbarDropdownHI" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Menu
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownHI">
<li><a class="dropdown-item" href="#">Action</a></li>
<li class="nav-item dropdown"><a class="dropdown-item dropdown-toggle" href="#">Submenu</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Submenu action</a></li>
<li><a class="dropdown-item" href="#">Another submenu action</a></li>
</ul>
</li>
<li class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">View All</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
You need to add custom styles along with the following html
.dropdown-submenu {
position: relative;
}
.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;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.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: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
<div class="container">
<div class="row">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
<li class="dropdown-item">Some action</li>
<li class="dropdown-item">Some other action</li>
<li class="dropdown-divider"></li>
<li class="dropdown-submenu">
<a class="dropdown-item" tabindex="-1" href="#">Hover me for more options</a>
<ul class="dropdown-menu">
<li class="dropdown-item"><a tabindex="-1" href="#">Second level</a></li>
<li class="dropdown-submenu">
<a class="dropdown-item" href="#">Even More..</a>
<ul class="dropdown-menu">
<li class="dropdown-item">3rd level</li>
<li class="dropdown-submenu"><a class="dropdown-item" href="#">another level</a>
<ul class="dropdown-menu">
<li class="dropdown-item">4th level</li>
<li class="dropdown-item">4th level</li>
<li class="dropdown-item">4th level</li>
</ul>
</li>
<li class="dropdown-item">3rd level</li>
</ul>
</li>
<li class="dropdown-item">Second level</li>
<li class="dropdown-item">Second level</li>
</ul>
</li>
</ul>
</div>
</div>
</div>

Bootstrap Dropdown Hoverable Dropdown menu using CSS only

I tried to make this part of my code hoverable using CSS only but didn't work, I followed steps right here, http://www.w3schools.com/howto/howto_css_dropdown.asp , But i couldn't put anything correctly in its place on my code, I either make the hoverable or instead i make the entire .list hoverable but yet the .list doesn't work hover hover
<nav class="navbar navbar-toggleable-md navbar-light">
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<div class="list">
<a class="dropdown-item" href="#">1</a>
<a class="dropdown-item" href="#">2</a>
<a class="dropdown-item" href="#">3</a>
<a class="dropdown-item" href="#">4</a>
<a class="dropdown-item" href="#">5</a>
</div>
</div>
</li>
</ul>
</div>
</nav>
CSS (What I've tried by myself)
<style>
.dropdown-menu {
visibility: hidden;
}
.dropdown-menu:hover > .list {
visibility: visible;
}
</style>
This is a strange structure, but the core of the issue was in your targetting of the wrong classes.
.dropdown{
display: block;
}
.dropdown-menu {
display: none;
}
.dropdown:hover .dropdown-menu {
display: block;
}
<nav class="navbar navbar-toggleable-md navbar-light">
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<div class="list">
<a class="dropdown-item" href="#">1</a>
<a class="dropdown-item" href="#">2</a>
<a class="dropdown-item" href="#">3</a>
<a class="dropdown-item" href="#">4</a>
<a class="dropdown-item" href="#">5</a>
</div>
</div>
</li>
</ul>
</div>
</nav>
.dropdown-menu:hovern .list {
visibility: visible;
}
this would work, You forgot to remove the '>' from the code that didn't allow css to access the list class, just remove'>' from the code and it may work.
in CSS, any class present in another class can be targeted by just writing the class name with '.'operator.
example- HTML code:
<div class="A">
<div class="B"></div>
</div>
CSS code:
.A .B{
}
this is how you access a subClass with parent class.

Resources