Bootstrap create third menu level with AdminLTE css - html

I'm currently using the AdminLTE template.
But I'm struggling with a third level menu. I've just tried with and without this plugin I'm using and I cannot figure out what I'm doing wrong, because my third level menu does not show up.
Here's the jsfiddle.
And also a image that shows what's going on.
I've read that since bootstrap 3 the dropdown-submenu was implemented, and I've tried to use it, without any success.
<ul class="dropdown-menu">
<li>Login</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">More options</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Second level</a></li>
<li class="dropdown-submenu">
More..
<ul class="dropdown-menu">
<li>3rd level</li>
<li>3rd level</li>
</ul>
</li>
</ul>
</li>
</ul>
I've searched around google and I found this example, which is the one I'm trying to implement.

As far as I know, bootstrap3 has no default multi-level dropdown functionality. What you are using as markup is taken from this "extension".
You are simply lacking the according CSS for this dropdown solution:
Add this to your stylesheet:
.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;
}
Your updated fiddle

Related

How can I customize bootstrap dropdown?

I'm a beginner in front-end development, I would like modify the behavior of bootstrap dropdown. In particular I would like to activate the second level with click and rather than hover. Also the first level items should be checkable, now if I click on it the dropdown closes.
I'm using this code: https://bootsnipp.com/snippets/kM4Q
You have tagged this question with bootstrap-4 tag, but you have added a link with bootstrap 3 files only, so in my answer I choose to use those files. This is a solution for Bootstrap 3 not 4.
To make that change, you could use jQuery, working with toggleClass function transforming also this CSS rule:
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
in this:
.dropdown-submenu > .dropdown-menu.active {
display: block;
}
To reset to initial situation when you close the dropdown menu, I added this function using Dropdown's event:
$('#mydropdown').on('hidden.bs.dropdown', function () {
$('ul', $(this)).removeClass("active");
})
This is the code:
$(document).ready(function(){
$('.dropdown-submenu > a').on("click", function(e){
$(this).next('ul').toggleClass("active");
e.preventDefault();
e.stopPropagation();
});
$('#mydropdown').on('hidden.bs.dropdown', function () {
$('ul', $(this)).removeClass("active");
})
});
.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 > .dropdown-menu.active {
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;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div id="mydropdown">
<div class="dropdown">
<a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="dropdown-menu" href="#">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
<li>Some action</li>
<li>Some other action</li>
<li class="divider"></li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Hover me for more options</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Second level</a></li>
<li class="dropdown-submenu">
Even More..
<ul class="dropdown-menu">
<li>3rd level</li>
<li>3rd level</li>
</ul>
</li>
<li>Second level</li>
<li>Second level</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>

CSS Cascade Menu: Position <div> relative to <li>

I want to build a cascade menu where at a certain <li> a new menu is opened. Here is the HTML code:
<div className='ux-dropdown-menu-container'>
<ul className='ux-dropdown-menu'>
<li className='ux-dropdown-menu-item'><a href='#'>Menu Item 1</a></li>
<li className='ux-dropdown-menu-item'><a href='#'>Menu Item 2</a></li>
<li className='ux-dropdown-menu-item'><a href='#'>Submenu</a></li>
<li className='ux-dropdown-menu-item'>
<div className='ux-dropdown-menu-container'>
<ul className='ux-dropdown-menu'>
<li className='ux-dropdown-menu-item'><a href='#'>SubMenu Item 1</a></li>
<li className='ux-dropdown-menu-item'><a href='#'>SubMenu Item 2</a></li>
<li className='ux-dropdown-menu-item'><a href='#'>SubMenu Item 3</a></li>
<li className='ux-dropdown-menu-item'>
</li>
</ul>
</div>
</li>
<li className='ux-dropdown-menu-item'><a href='#'>Menu Item 3</a></li>
</ul>
</div>
And my CSS classes:
.ux-dropdown-menu-container {
position: absolute;
display: block;
background-color: $ux-color-boxed-background;
border: solid;
border-color: $ux-color-border;
border-width: 1px;
border-radius: 4px;
box-shadow: 0px 2px 2px 0px $ux-color-border;
top: 105%;
text-align: left;
min-width: 100px;
}
.ux-dropdown-menu {
margin: 0px 0px 0px 0px;
list-style-type: none;
padding: 5px 5px 5px 5px; // top right botton left
z-index: 1;
}
.ux-dropdown-menu-item
{
white-space: nowrap;
position: relative;
}
.ux-dropdown-menu-item a {
display: inline-block;
text-decoration: none;
padding: 5px 5px 5px 5px;
color: $ux-color-text;
}
.ux-dropdown-menu-item:hover {
background-color: $ux-color-hover;
}
.ux-dropdown-menu-item:active {
background-color: $ux-color-click-background;
}
Even having a position: relative at my <li>, the new <div> for the submenu is not positioning there. Here is the result:
I expected the submenu to appear right at the side of the Submenu item.
I am now looking to:
(A) position the submenu right next to the Submenu item
(B) consider right or left opening, in case the menu is composed and the right side of the screen, where it then needs to open the menu to the left. I do not plan to use jQuery
body{
margin: 0; padding: 0;
}
.ux-dropdown-menu-container {
float: left;
}
.ux-dropdown-menu-containerItem {
position: absolute;
display: none;
background-color: $ux-color-boxed-background;
border: solid;
border-color: $ux-color-border;
border-width: 1px;
border-radius: 4px;
box-shadow: 0px 2px 2px 0px $ux-color-border;
top: 0;
text-align: left;
min-width: 100px;
left: 100%;
}
.ux-dropdown-menu-item:hover .ux-dropdown-menu-containerItem {
display: block;
}
.ux-dropdown-menu {
margin: 0px 0px 0px 0px;
list-style-type: none;
padding: 5px 5px 5px 5px; // top right botton left
z-index: 1;
}
.ux-dropdown-menu-item
{
white-space: nowrap;
position: relative;
border: 1px solid #ccc;
list-style: none;
}
.ux-dropdown-menu-item a {
display: inline-block;
text-decoration: none;
padding: 5px 5px 5px 5px;
color: $ux-color-text;
}
.ux-dropdown-menu-item:hover {
background-color: $ux-color-hover;
}
.ux-dropdown-menu-item:active {
background-color: $ux-color-click-background;
}
<div class="ux-dropdown-menu-container">
<ul class="ux-dropdown-menu">
<li class="ux-dropdown-menu-item">Menu Item 1</li>
<li class="ux-dropdown-menu-item">Menu Item 2</li>
<li class="ux-dropdown-menu-item">
Submenu
<div class="ux-dropdown-menu-containerItem">
<ul class="ux-dropdown-menu">
<li class="ux-dropdown-menu-item">SubMenu Item 1</li>
<li class="ux-dropdown-menu-item">SubMenu Item 2</li>
<li class="ux-dropdown-menu-item">SubMenu Item 3</li>
</ul>
</div>
</li>
<li class="ux-dropdown-menu-item">Menu Item 3</li>
</ul>
</div>

How to passing an `<ul>` over the other element

I want to make my app responsive but I just founded a problem with a <ul>, when I reduce the windows he disapear but I want to make it pass over the other elements (look the images)
This is ok :
But this is not ok :
He changes side when I reduce the window...
So that's the HTML of the 3 options
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li>
<i class="fa fa-wrench"></i>
<ul class="dropdown-menu" role="menu">
<li><a id="allMch">All machines</a>
</li>
<li><a id="rngMch">Only running machines</a>
</li>
<li><a id="stpMch">Only stopped machines</a>
</li>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
And the css of dropdown-menu:
.dropdown-menu {
overflow: auto;
border: medium none;
box-shadow: none;
display: none;
// float: left;
font-size: 12px;
left: 0;
list-style: none outside none;
padding: 0;
// position: absolute;
text-shadow: none;
top: 100%;
z-index: 9998;
border: 1px solid #D9DEE4;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.dropdown-menu>li>a {
color: #5A738E;
}
If #nashcheez put an answer with his code I'll mark is as answer but the solution for me was to add this code in the css :
.panel_toolbox>li>ul {
left:auto;
right:0;
position: absolute;
}

Bootstrap class dropdown-menu dropdown-menu-right is not working on self-defined sub-menu's

In related to my previous question (Dropdown submenu on bootstrap is not working)
I'm currently building a sub-menu for a sub-menu of an li dropdown. So it means that it is nested. Under the banking menu there is transaction dropdown menu and below the transaction dropdown there is a menu for different type of transactions.
By the way, I've successfully created it BUT the submenu of the "transaction" module appears on the front of the transaction menu during hover, blocking the parent menu which is the transaction. How can I avoid it and place it on the right side of the transaction menu during hover? Anyways, I've done using "dropdown-menu dropdown-menu-right" but it doesnt change the output of the program. I think there is something wrong with my CSS.
HTML CODE:
<li class='dropdown'><a id = 'dLabel' class='dropdown-toggle active' data-toggle='dropdown' href='#'><img src = 'images/forbank.png' height = 35 width = 35>Banking<span class='caret'></span></a>
<ul class='dropdown-menu' role='menu' aria-labelledby='dropdownMenu'>
<li class = 'dropdown-submenu'>
<a tabindex = '-1' href='#'><span class = 'glyphicon glyphicon-cog'> </span> Transaction </a>
<ul class='dropdown-menu dropdown-menu-right' aria-labelledby='dLabel'>
<li><a tabindex='-1' href='#'> Withdrawal / Deposit </a></li>
<li><a tabindex='-1' href='#'> Fixed Deposit </a></li>
</ul>
</li>
<li role='separator' class='divider'></li>
<li><a href='#'><span class='glyphicon glyphicon-list-alt'> </span> Summaries </a></li>
<li><a href='#'><span class='glyphicon glyphicon-wrench'> </span> Settings </a></li>
</ul>
</li>
CSS CODE:
.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;
}
For anyone who stumbles upon this in the future. Refer to https://github.com/twbs/bootstrap/issues/23553.
It seems bootstrap4's dropdown-menu-right is not working outside navbars. Jipexu's hack worked for me :
.dropdown-menu-right {
right: 0;
left: auto;
}
Try this css
/* dropdown open on right side of the menu*/
.dropdown-menu {
top: 0;
left: 100%;
}
I tried a slight variation to Siddharth Garg answer above.
<div class="dropdown-menu dropdown-menu-right">
.dropdown-menu-right {
padding-left: 10px;
}
This works and allows me to set the padding.

Dropdown-submenu not functional even after adding it to CSS and implementing in html

I am using bootstrap v3.0.0. I am aware that this does not support dropdown-submenu. Lot of solutions posted on stackoverflow and other sources provided the "dropdown-submenu" CSS that I added to my Bootstrap.css and also made changes to my HTML.
And here is my HTML:
<li id="navPayments" class="dropdown">
Movies<b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Scary</a>
<ul class="dropdown-menu">
<li style="display: block; width: 100%">#this.Html.ActionLink("Voilent", "Voilent", "Movies")</li>
<li style="display: block; width: 100%">#this.Html.ActionLink("Extortion", "Extortion", "Movies")</li>
<li style="display: block; width: 100%">#this.Html.ActionLink("Evil", "Evil", "Movies")</li>
</ul>
</li>
</ul>
</li>
Here is the CSS:
.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 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:#cccccc;
margin-top:5px;
margin-right:-10px;
}
.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 0 6px 6px;
-moz-border-radius:6px 0 6px 6px;
border-radius:6px 0 6px 6px;
}
I see the menu Scary inder Movies but it does not bring up the sub-menus when I hover over that. I am not sure what I am missing here. And it also does not show the little right arrow beside "Scary" menu.
It looks like you're using Skelly's sub menu dropdown solution
Here is a stripped down† version with comments so you can follow along with each rule:
HTML:
<!-- Parent Menu -->
<ul class="dropdown-menu" id="parentMenu"
role="menu" aria-labelledby="dropdownMenu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<!-- Child Menu -->
<li class="dropdown-submenu">
<a tabindex="-1" href="#">More options</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Second level</a></li>
<li>Second level</li>
<li>Second level</li>
</ul>
</li>
</ul>
CSS:
/* Helps position submenu */
.dropdown-submenu {
position: relative;
}
/* Positions and styles child menu */
.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;
}
/* Makes submenu visible when hovering */
.dropdown-submenu:hover > .dropdown-menu {
display:block;
}
/* Adds caret to submenu links */
.dropdown-submenu>a:after {
float: right;
content: "►";
}
†
Took out cool css triangle and pretty formatting for left opening menus with pull-left class.
Demo in jsFiddle
Compare this version with your output.
Try to convert it over until it breaks, and tell us where you get stuck.
PS: It looks like it's working just fine