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>
Related
I have 1 row of 3 divs. The rows on the edges (1,3) are arrow indicators. Edge/Column 1 has an arrow indicating left; edge/column3 has an arrow indicating right. The middle column (2) is scrollable. I want for when the middle column, the edges remain intact.
In the code example. The first column remains while the middle column scroll but the third column (right arrow) disappears.
Please and thank you in advanced.
body {
font-family: sans-serif;
color: #3d85c6;
}
.letter-changer {
animation: example 5s linear 2s infinite alternate;
}
ul.mp-0,
.mp-0 {
margin: 0;
padding: 0;
}
div.lk-shadow{
-webkit-box-shadow: 5px 7px 9px 0px rgba(0, 0, 0, 0.6);
box-shadow: 5px 7px 9px 0px rgba(0, 0, 0, 0.6);
}
div.lk-verb-box {
position: relative;
overflow: hidden;
vertical-align: middle;
width: 300;
min-width: 150px;
white-space: nowrap;
overflow-x: auto;
}
div.lk-verb-border {
margin: 5px;
}
.lk-scroll-arrow {
height: 10px;
width: 10px;
text-align: center;
line-height: 40px;
vertical-align: middle;
}
ul.lk-verb {
list-style: none;
padding: 0%;
word-spacing: 0%;
white-space: nowrap;
overflow-y: hidden;
overflow-x: auto;
display: block;
padding: 5px;
}
li.lk-verb {
display: inline-block;
background-color: white;
color: #3d85c6;
border: solid 1px #3d85c6;
height: 20px;
padding: 5px;
padding-left: 7px;
padding-right: 7px;
border-radius: 5px;
}
li.lk-verb:hover {
background-color: #3d85c6;
color: white;
cursor: pointer;
}
.lk-fl {
float: left;
}
.lk-ele-box {
overflow-x: auto;
}
#keyframes example {
from {
transform: translateX(0);
}
to {
transform: translateX(140px);
}
}
</style>
<script type="text/javascript">
document.addEventListener("keypress", function (e) {
var el = document.getElementById("vbr10");
el.scrollIntoView(true);
});
<div class="lk-shadow" style="padding-right: 5px;">
<div class="lk-scroll-arrow lk-fl" style="display: table-cell;">🢔</div>
<div class="lk-verb-box" >
<ul class="lk-verb mp-0 lk-fl">
<li id="vrb1" class="lk-verb">Element 1</li>
<li id="vrb2" class="lk-verb">Element 1</li>
<li id="vrb3" class="lk-verb">Element 2</li>
<li id="vrb4" class="lk-verb">Element 0</li>
<li id="vrb5" class="lk-verb">Element 3</li>
<li id="vrb6" class="lk-verb">Element 4</li>
<li id="vrb7" class="lk-verb">Element 5</li>
<li id="vrb8" class="lk-verb">Element 6</li>
<li id="vrb9" class="lk-verb">Element 7</li>
<li id="vrb10" class="lk-verb">Element 8</li>
<li id="vrb11" class="lk-verb">Element 9</li>
</ul>
<div class="lk-scroll-arrow lk-fl" style="display: table-cell;">🢖</div>
</div>
</div>
I want to remove the border that I have under the sub menu -"View All clients", "Add New Clients". any help would be really appreciated. The picture is attached here has the menu and sub-menu that I want to remove the border https://i.stack.imgur.com/GKLgZ.png
.help-left-menu {
list-style: none;
margin-top: 36px;
padding-left: 18px;
overflow: auto;
}
.help-left-menu li {
padding: 5px 8px;
border-bottom: 1px solid #CCC;
background: rgba(119, 140, 162, 1);
text-decoration: none;
}
.help-left-menu li {
list-style: none;
}
#dropdown-items {
display: none;
padding-left: 2px;
}
#dropdown-items a {
color: white;
}
.menu {
color: white;
}
.dropdown-list li a.active {
background: darkslategray;
border: 1px solid darkgray;
padding: 10px;
}
.tab-content {
display: none
}
.config-left {
margin-top: 36px;
}
.content-heading {
background-color: rgba(119, 140, 162, 1);
padding-top: 5px;
padding-bottom: 1px;
color: white;
align-content: center;
text-align: center;
}
.features {
padding-top: 4px;
padding-bottom: 10px;
color: white;
padding-left: 0px;
margin-left: 20px;
}
<ul class="help-left-menu">
<li class="dropdown-list">
<div class="features">
<h5>FEATURES</h5>
</div>
<a href="#" data-toggle="dashboard-content" class="dashboard menu
tab">DASHBOARD<i class="dropdown-icon"></i></a>
</li>
<li class="dropdown-list"><a href="#" data-toggle="new-proposal-
content" class="newProposal menu tab">NEW PROPOSAL<i class="dropdown-
icon"></i></a></li>
<li class="dropdown-list">PROPOSALS<i class="dropdown-icon"></i>
</li>
<li class="dropdown-list"><a href="#" data-toggle="client-
content" class="clients menu">CLIENTS<i class="dropdown-icon"></i>
<ul class="submenu" id="dropdown-items">
<li><a href="#" data-toggle="view-all-client-content"
class="view-allClients submenu tab">View All Clients</a>
</li>
<li><a href="#" data-toggle="add-new-client-content" class="add-
newClient submenu tab">Add New Clients</a>
</li>
</ul>
Use something like this:
.help-left-menu li {
border-bottom: 1px solid #CCC;
}
.submenu li {
border: 0;
}
.submenu a {
font-size: 40px;
color: red;
text-decoration: none;
}
<ul class="help-left-menu">
<li class="dropdown-list">
<div class="features">
<h5>FEATURES</h5>
</div>
<a href="#" data-toggle="dashboard-content" class="dashboard menu
tab">DASHBOARD<i class="dropdown-icon"></i></a>
</li>
<li class="dropdown-list"><a href="#" data-toggle="new-proposal-
content" class="newProposal menu tab">NEW PROPOSAL<i class="dropdown-
icon"></i></a></li>
<li class="dropdown-list">PROPOSALS<i class="dropdown-icon"></i>
</li>
<li class="dropdown-list"><a href="#" data-toggle="client-
content" class="clients menu">CLIENTS<i class="dropdown-icon"></i>
<ul class="submenu" id="dropdown-items">
<li><a href="#" data-toggle="view-all-client-content"
class="view-allClients submenu tab">View All Clients</a>
</li>
<li><a href="#" data-toggle="add-new-client-content" class="add-
newClient submenu tab">Add New Clients</a>
</li>
</ul>
If you have used border: none in your CSS selector, make sure to try adding !important or adding a higher specificity to it in case anything has higher specificity than it.
This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
CSS align few items on both side with flexbox [duplicate]
(1 answer)
Closed 3 years ago.
I'm implementing navigation bar of github and wanna align two parts at the left and right. Therefore, I used float property, but it didn't work for my code. What is wrong with me?
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
JSFIDDDLE
Flexbox ignores floats.
Instead, use margin to separate the left navigation items from the right navigation items.
A common pattern is a navigation bar where some key items are aligned to the right, with the main group on the left.
Auto margins will take up all of the space that they can in their axis — it is how centering a block with margin auto left and right works.
Using auto margins for main axis alignment
Consider using the adjacent sibling combinator to target the first navigation__right element that follows a navigation__left element, and setting margin-left:auto.
.navigation__left + .navigation__right {
margin-left: auto;
}
Demonstration:
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__right {
border: 2px solid blue;
}
.navigation__left+.navigation__right {
margin-left: auto;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
Incidentally, the Github navigation you referenced has a somewhat more complex structure and uses nested flexboxes.
In this case dont use Flex.
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
You can set display:flex to inline-block
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: inline-block;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
Remove the display:flex property
.navigation {
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
I have two lists sitting side-by-side. In the full code there will be the ability to select one of the list items from the MainList which will show the relevant list items from the SubList. What I would like is for the border-right of the MainList to overlap the border-left of the SubList to make it look like the SubList items are being shown as a result of the selection in the MainList.
ul {
list-style: none;
}
.BigContainer {
border: 2px solid #d50f67;
border-radius: 5px;
margin: 10px 0;
padding: 5px;
overflow: auto;
}
.MainListContainer {
width: 50%;
float: left;
}
.MainListItem {
border-bottom: 1px solid #ddd;
border-right: 1px solid white;
padding: 5px;
z-index: 2;
}
.MainListItem:last-of-type {
border: none;
}
.SubListContainer {
width: 45%;
float: left;
border: 1px solid #ddd;
border-radius: 5px;
}
.SubListItem {
padding: 5px;
z-index: 1;
}
<div class="BigContainer">
<div class="MainListContainer">
<ul class="MainList">
<li class="MainListItem">List Option A</li>
<li class="MainListItem">List Option B</li>
<li class="MainListItem">List Option C</li>
</ul>
</div>
<div class="SubListContainer">
<ul class="SubList">
<li class="SubListItem">Sub-Option 1</li>
<li class="SubListItem">Sub-Option 2</li>
<li class="SubListItem">Sub-Option 3</li>
<li class="SubListItem">Sub-Option 4</li>
<li class="SubListItem">Sub-Option 5</li>
</ul>
</div>
</div>
So, the border-right of the MainList would be white/transparent to basically erase a portion of the SubList border. I appreciate that, at the moment, making this happen would remove more of the SubList border than desired, but I will code the selection process properly to ensure only the selected item has the relevant border styling applied.
Add selected class to the selected item, then add
.selected:after{
content:"";
position: absolute;
right:-2px;
top:0;
width: 1px;
height: 100%;
background-color: white;
}
This will be placed right where you want it to. Note that MainListItem needs to have a position: relative; for the position to work.
.selected:after{
content:"";
position: absolute;
right:-2px;
top:0;
width: 1px;
height: 100%;
background-color: white;
}
ul {
list-style: none;
}
.BigContainer {
border: 2px solid #d50f67;
border-radius: 5px;
margin: 10px 0;
padding: 5px;
overflow: auto;
}
.MainListContainer {
width: 50%;
float: left;
}
.MainListItem {
border-bottom: 1px solid #ddd;
border-right: 1px solid white;
padding: 5px;
z-index: 2;
position: relative;
}
.MainListItem:last-of-type {
border: none;
}
.SubListContainer {
width: 45%;
float: left;
border: 1px solid #ddd;
border-radius: 5px;
}
.SubListItem {
padding: 5px;
z-index: 1;
}
<div class="BigContainer">
<div class="MainListContainer">
<ul class="MainList">
<li class="MainListItem">List Option A</li>
<li class="MainListItem selected">List Option B</li>
<li class="MainListItem">List Option C</li>
</ul>
</div>
<div class="SubListContainer">
<ul class="SubList">
<li class="SubListItem">Sub-Option 1</li>
<li class="SubListItem">Sub-Option 2</li>
<li class="SubListItem">Sub-Option 3</li>
<li class="SubListItem">Sub-Option 4</li>
<li class="SubListItem">Sub-Option 5</li>
</ul>
</div>
</div>
I have a main menu bar that has a drop down menu and that menu has a sub menu. How do I get the sub drop down menu to display to the left of "drop down 2" link in the first drop down menu? I would also like to align the top of the sub menu to the top of the "drop down 2" link. Right now it's appearing below and to the left of the link.
HTML:
<img src="#" width="100%" height="100px">
<div class="TopMenuBar">
<ul>
<li>Side</li>
<li class="dropdown">menu
<div class="dropdown-menu">
<ul>
<li>drop down 1</li>
<li class="sub-dropdown">drop down 2
<div class="sub-dropdown-menu">
<ul>
<li>sub drop down 1</li>
<li>sub drop down 2</li>
</ul>
</div>
</li>
<li>drop down 3</li>
</ul>
</div>
</li>Bar</li>
</ul>
</div>
<div class="SideMenuBar">
<ul>
<li>Side</li>
<li>Menu</li>
<li>Bar</li>
</ul>
</div>
<h1>h1 Header</h1>
<main>
<h2>h2 Header</h2>
<p>Main paragraph</p>
Main link
<ul>
<li>Main list item</li>
<li>Main list item</li>
<li>Main list item</li>
</ul>
<h2>h2 Header</h2>
<p>Main paragraph</p>
Main link
<ul>
<li>Main list item</li>
<li>Main list item</li>
<li>Main list item</li>
</ul>
</main>
CSS:
.TopMenuBar {
border: none;
background-color: purple;
width: 100%;
margin: 0;
padding: 0;
}
.TopMenuBar>ul {
display: flex;
justify-content: space-between;
margin: 0;
padding: 0;
}
.TopMenuBar>ul, .dropdown-menu>ul, .sub-dropdown-menu>ul{
list-style-type: none;
margin: 0;
padding: 0;
}
.TopMenuBar>li {
display: inline;
}
.TopMenuBar a, .dropdown-menu a, .sub-dropdown-menu a{
color: white;
text-decoration: none;
padding: 20px;
display: block
}
/* Applys to all links under class TopMenuBar on hover */
.TopMenuBar a:hover {
background-color: #b14eb1;
color: black;
}
.dropdown-menu {
}
.dropdown-menu, .sub-dropdown-menu{
display: none;
background-color: purple;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
position: absolute;
z-index: 1;
}
/* Applys to all links under class TopMenuBar */
.dropdown-menu a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown:hover .dropdown-menu{
display: block;
}
.sub-dropdown:hover .sub-dropdown-menu{
display: table;
}
.SideMenuBar {
background-color: orange;
margin-left: 20px;
margin-top: 0;
display: flex;
height: 100vh;
float: left;
}
.SideMenuBar ul {
padding: 0;
margin: 0;
list-style-type: none;
justify-content: space-between;
display: flex;
flex-direction: column;
}
.SideMenuBar li a {
color: white;
text-decoration: none;
padding: 20px;
display: list-item;
}
.SideMenuBar li a:hover {
background-color: #fcbf7e;
color: black;
}
main {
padding-left: 10px;
display: table
}
h1 {
text-align: center;
}
here is a working model at codepen
Add this to the bottom of your stylesheet.
.sub-dropdown{
position: relative;
}
.sub-dropdown-menu{
left: 100%;
top: 0;
}
more here http://codepen.io/hunzaboy/pen/jyRoWB
See This code example, It may help you
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style type="text/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;
}
</style>
</head>
<body>
<div class="container">
<br>
<div class="row">
<div class="dropdown">
<a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="/page.html">
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>
</body>
</html>