Reputation: 12649
I was wondering if it was possible to extend the dropdowns. I think you will understand what I mean once I describe it but I just don't know the name for it. So after you open the initial dropdown. You may have child elements that may open another dropdown-esque menu, in this case to the right, which may provide more precise options. So for instance...
Menu
v
option1 -> precise1
option2 precise2
precise3
There doesn't seem to be anything in the components documentation describing this behaviour.
Upvotes: 0
Views: 1260
Reputation: 53
This is something I wrote for another project.
HTML
<div class="dropdown">
<a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="#">
Menu <span class="caret"></span>
</a>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
<li><a href="#">Option 1</a></li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Option 2</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Precise 1 </a></li>
<li><a href="#">Precise 2</a></li>
<li class="dropdown-submenu">
<a href="#">More precise </a>
<ul class="dropdown-menu">
<li><a href="#">Precise 3</a></li>
<li><a href="#">Precise 4</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
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;
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;
}
Upvotes: 1