I'm currently tackling a CSS-only menu project, but I'm struggling with keeping the sub-menu visible when moving away from the li element.
The height should span 100% of the page, and the sub-menu should mirror the main menu, appearing to the right.
Any tips or advice on this would be greatly appreciated!
Check out the demo (http://jsfiddle.net/91t43ruo/1/)
<div class="wrapper">
<div class="main-menu">
<ul>
<li><a href="#">Lorem ipsum</a></li>
<li><a href="#">Sed id cursus</a></li>
<li><a href="#">Co-Investor</a></li>
<li class="has-sub-menu"><a href="#">Donec interdum</a>
<div class="sub-menu">
<ul>
<li><a href="#">Ut quis bibendum</a></li>
<li><a href="#">Praesent vestibulum</a></li>
<li><a href="#">Sed ultrices</a></li>
</ul>
</div>
</li>
<li><a href="#">Morbi a mi blandit</a></li>
<li><a href="#">Pellentesque</a></li>
</ul>
</div>
</div>
body, html{
height:100%;
margin:0;
font-family:Arial;
}
a {
cursor: pointer;
text-decoration: none;
}
/*Wrapper*/
.wrapper {
width: 100%;
height: 100%;
background-color: #CCC;
}
/* Menu */
.main-menu, .sub-menu {
background-color: #2F759B;
width: 200px;
height: calc(100% - 40px);
padding: 20px;
}
.main-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.main-menu li {
color: white;
background-color: #3585B0;
line-height: 26px;
margin-bottom: 5px;
}
.main-menu li:hover, .main-menu li.has-sub-menu{
background-color: #43A8DD;
cursor: pointer;
}
.main-menu a {
color: inherit;
margin-left: 6px;
}
/*Sub Menu*/
.sub-menu {
display:none;
position: absolute;
top: 0;
left: 240px;
}
.sub-menu ul {
}
/*Hover*/
.main-menu li:hover > div.sub-menu{
display:block;
}