HTML menu with CSS hover - html

I'm working on an HTML menu.
I have a problem with the "L3 submenu" (Item-221, Item-222).
When I "mouse in" to Item-22, L3 is displayed. It's ok.
But I can't click either Item-221 or Item-222.
If I "mouse out" Item-22, then L3 disappear.
Is there a solution for this using (only) CCS?
CSS code:
ul {
background-color: #c4c4c4;
list-style-type: none;
display: flex;
}
li {
padding: 5px 10px 5px 10px;
white-space: nowrap;
position: relative;
}
li:hover {
background-color: #02DB02;
}
.menu li>ul {
padding: 10px 13px 10px 13px;
position: absolute;
display: none;
top: calc(100%);
left: -8px;
}
#it_2:hover #ul_2, #it_22:hover #ul_3 {
display: block;
}
.menu>li>ul>li>ul {
top: -0.5em;
left: calc(100% + 10px);
}
HTML code:
<ul class="menu">
<li>Item-1</li>
<li id="it_2">Item-2
<ul id="ul_2">
<li>Item-21</li>
<li id="it_22">Item-22
<ul id="ul_3">
<li>Item-221</li>
<li>Item-222</li>
</ul>
</li>
</ul>
</li>
<li>Item-3</li>
</ul>

It is better to put padding on the list item so the sub-menu won't disappear
ul {
background-color: #c4c4c4;
list-style-type: none;
display: flex;
}
li {
padding: 5px 10px 5px 10px;
white-space: nowrap;
position: relative;
}
li:hover {
background-color: #02DB02;
}
.menu ul > li {
position:relative;
padding: 0 13px 0 13px;
}
.menu li>ul {
padding: 10px 0 10px 0;
position: absolute;
display: none;
top: calc(100%);
left: -8px;
}
#it_2:hover #ul_2, #it_22:hover #ul_3 {
display: block;
}
.menu>li>ul>li>ul {
position: absolute;
top: -0.5em;
left: calc(100%);
padding: 1em;
}
<ul class="menu">
<li>Item-1</li>
<li id="it_2">Item-2
<ul id="ul_2">
<li>Item-21</li>
<li id="it_22">Item-22
<ul id="ul_3">
<li>Item-221</li>
<li>Item-222</li>
</ul>
</li>
</ul>
</li>
<li>Item-3</li>
</ul>

Related

How to make menu remain visible while on hover

I've created a submenu which appears when you hover over the 'services' link. However, when I move my mouse over to the submenu it disappears due to it sitting below the navigation where I want it to be.
So far I’ve tried leaving the submenu in its natural top position and using z-index to make it sit behind the navigation. I found that this wouldn't work due to the submenu being positioned absolute.
body {
font-family: acumin-pro, sans-serif;
font-size: 16px;
letter-spacing: .25px;
margin: 0;
}
.header {
display: flex;
width: 100%;
}
.nav {
width: 80%;
margin: auto;
position: relative;
}
.nav a {
color: #000;
}
.nav ul:hover li a {
color: #eee
}
.nav ul li:hover a {
color: #333;
}
.nav a:last-child {
margin: 0px;
}
.nav ul {
list-style: none;
padding: 0px;
}
.nav ul li {
display: inline-block;
margin: 0 35px 0 0;
}
.three:hover>.sub-menu {
display: block;
opacity: 1
}
.sub-menu {
height: 200px;
position: absolute;
top: 100%;
background: #333;
display: none;
opacity: 0;
left: 0;
right: 0;
}
<div class="header">
<div class="nav">
<ul>
<li>
<a class="one">Home</a>
</li>
<li>
<a class="two">About</a>
</li>
<li class="three">
<a class="">Services</a>
<div class="sub-menu"></div>
</li>
<li>
<a class="four">Contact</a>
</li>
</ul>
</div>
</div>
The submenu should sit exactly below the navigation and stay visible when I move my mouse across from the link to the submenu.
I have included padding-bottom: 20px; on hover
the link need to be connected to the submenu so that it is still hovered
body {
font-family: acumin-pro, sans-serif;
font-size: 16px;
letter-spacing: .25px;
margin: 0;
}
.header {
display: flex;
width: 100%;
}
.nav {
width: 80%;
margin: auto;
position: relative;
}
.nav a {
color: #000;
}
.nav ul:hover li a {
color: #eee
}
.nav ul li:hover a {
color: #333;
padding-bottom: 20px;
}
.nav a:last-child {
margin: 0px;
}
.nav ul {
list-style: none;
padding: 0px;
}
.nav ul li {
display: inline-block;
margin: 0 35px 0 0;
}
.three:hover>.sub-menu {
display: block;
opacity: 1
}
.sub-menu {
height: 200px;
position: absolute;
top: 100%;
background: #333;
display: none;
opacity: 0;
left: 0;
right: 0;
}
<div class="header">
<div class="nav">
<ul>
<li>
<a class="one">Home</a>
</li>
<li>
<a class="two">About</a>
</li>
<li class="three">
<a class="">Services</a>
<div class="sub-menu"></div>
</li>
<li>
<a class="four">Contact</a>
</li>
</ul>
</div>
</div>
Remove margin .nav ul & add padding for .nav a
.nav ul {
list-style: none;
padding: 0px;
margin:0;
}
.nav a {
color: #000;
padding: 10px 0;
display: block;
}
body {
font-family: acumin-pro, sans-serif;
font-size: 16px;
letter-spacing: .25px;
margin: 0;
}
.header {
display: flex;
width: 100%;
}
.nav {
width: 80%;
margin: auto;
position: relative;
}
.nav a {
color: #000;
padding: 10px 0;
display: block;
}
.nav ul:hover li a {
color: #eee
}
.nav ul li:hover a {
color: #333;
}
.nav a:last-child {
margin: 0px;
}
.nav ul {
list-style: none;
padding: 0px;
margin:0;
}
.nav ul li {
display: inline-block;
margin: 0 35px 0 0;
}
.three:hover>.sub-menu {
display: block;
opacity: 1
}
.sub-menu {
height: 200px;
position: absolute;
top: 100%;
background: #333;
display: none;
opacity: 0;
left: 0;
right: 0;
}
<div class="header">
<div class="nav">
<ul>
<li>
<a class="one">Home</a>
</li>
<li>
<a class="two">About</a>
</li>
<li class="three">
<a class="">Services</a>
<div class="sub-menu"></div>
</li>
<li>
<a class="four">Contact</a>
</li>
</ul>
</div>
</div>
I used this.
body {
font-family: acumin-pro, sans-serif;
font-size: 16px;
letter-spacing: .25px;
margin: 0;
}
.header {
display: flex;
width: 100%;
}
.nav {
width: 80%;
margin: auto;
position: relative;
}
.nav a {
color: #000;
}
.nav ul:hover li a {
color: #eee
}
.nav ul li:hover a {
color: #333;
}
.nav a:last-child {
margin: 0px;
}
.nav ul {
list-style: none;
padding: 0px;
}
.nav ul li {
display: inline-block;
margin: 0 35px 0 0;
}
.three:hover>.sub-menu {
display: block;
opacity: 1
}
.sub-menu {
height: 200px;
position: absolute;
top: 100%;
background: #333;
opacity: 0;
left: 0;
right: 0;
display: none;
}
.sub-menu::before {
content: "";
top: -18px;
width: 100%;
height: 20px;
position: absolute;
}
<div class="header">
<div class="nav">
<ul>
<li>
<a class="one">Home</a>
</li>
<li>
<a class="two">About</a>
</li>
<li class="three">
<a class="">Services</a>
<div class="sub-menu"></div>
</li>
<li>
<a class="four">Contact</a>
</li>
</ul>
</div>
</div>
Just replace this to your existing css, nothing else.
.nav a {
color: #000;
padding-bottom: 20px;
display: inline-block;
}
.nav ul {
list-style: none;
padding: 0px;
margin: 0;
}

css second level dropdowns disappearing

My issue is the Html/Css dropdown second level disappears ans I move the cursor, currently works fine on Safari on Iphone but no other browsers I have tried.
Seems to be something to do with the width in the CSS, if I set a fixed px value all seems to fuction but then it does not reize correctly for all screens.
All parameters are % based througout the site and so far that is working fine cross platform.
.third-level-menu {
position: absolute;
top: 0;
width: auto;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu>li {
height: 30px;
background: #FFF;
}
.third-level-menu>li:hover {
background: #FFF;
}
.second-level-menu {
position: absolute;
top: 30px;
left: 0;
height: auto;
width: auto;
list-style: none;
padding: 0;
margin: 0;
display: none;
z-index: 100;
}
.second-level-menu>li {
position: relative;
height: auto;
background: #FFF;
width: auto;
}
.second-level-menu>li:hover {
background: #FFF;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu>li {
position: relative;
float: left;
height: auto;
width: auto;
}
.top-level-menu>.style4 {
float: left;
height: auto;
position: relative;
width: auto;
padding-top: 0px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
}
.top-level-menu>li:hover {
background: #FFF;
}
.top-level-menu li:hover>ul {
/* On hover, display the next level's menu */
display: inline;
white-space: nowrap;
}
.top-level-menu a {
font: bold 14px Arial, Helvetica, sans-serif;
color: #093;
text-decoration: none;
padding: 0 0 0 10px;
display: block;
line-height: auto;
}
.top-level-menu a:hover {
color: #3F6;
white-space: nowrap
}
.top-level-menu a {
color: #093;
white-space: nowrap
}
<div id="topmenu">
<ul class="top-level-menu">
<li>Home</li>
<li class="style4">//</li>
<li>Eeeeeeeeee eeeeeeeeeee
<ul class="second-level-menu">
<li>Dddddddd</li>
<li>Dddddddddd</li>
<li>Dddddddddd</li>
</ul>
<li class="style4">//</li>
<li>AAAAAAAAAA
<ul class="second-level-menu">
<li>Two long words</li>
<li>Two very long words</li>
</ul>
<li class="style4">//</li>
<li>Two long words</li>
<li class="style4">//</li>
<li>two words
<ul class="second-level-menu">
<li>single</li>
<li>single</li>
<li class="style4">//</li>
</ul>
<li class="style4">//</li>
<li>Eeeeeee</li>
</ul>
</div>
There is a gap between your main menu and second level menu. Because of that your hover effect is no longer exist. To check try this code
.top-level-menu > li > a { border: 1px solid blue; }
.second-level-menu { border: 1px solid red; }
and to resolve this use
.top-level-menu > li > a { padding:8px 0px; }
Removing top:30px from .second-level-menu will fix the issue.
If you want some gap between the main menu and the second level menu. You can give some padding to the first menu option by adding below-given css -
.second-level-menu > li:first-child {
padding-top: 10px;
}
.third-level-menu {
position: absolute;
top: 0;
width: auto;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu>li {
height: 30px;
background: #FFF;
}
.third-level-menu>li:hover {
background: #FFF;
}
.second-level-menu {
position: absolute;
left: 0;
height: auto;
width: auto;
list-style: none;
padding: 0;
margin: 0;
display: none;
z-index: 100;
}
.second-level-menu>li {
position: relative;
height: auto;
background: #FFF;
width: auto;
}
.second-level-menu>li:hover {
background: #FFF;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu>li {
position: relative;
float: left;
height: auto;
width: auto;
}
.top-level-menu>.style4 {
float: left;
height: auto;
position: relative;
width: auto;
padding-top: 0px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
}
.top-level-menu>li:hover {
background: #FFF;
}
.top-level-menu li:hover>ul {
/* On hover, display the next level's menu */
display: inline;
white-space: nowrap;
}
.top-level-menu a {
font: bold 14px Arial, Helvetica, sans-serif;
color: #093;
text-decoration: none;
padding: 0 0 0 10px;
display: block;
line-height: auto;
}
.top-level-menu a:hover {
color: #3F6;
white-space: nowrap
}
.top-level-menu a {
color: #093;
white-space: nowrap
}
<div id="topmenu">
<ul class="top-level-menu">
<li>Home</li>
<li class="style4">//</li>
<li>Eeeeeeeeee eeeeeeeeeee
<ul class="second-level-menu">
<li>Dddddddd</li>
<li>Dddddddddd</li>
<li>Dddddddddd</li>
</ul>
<li class="style4">//</li>
<li>AAAAAAAAAA
<ul class="second-level-menu">
<li>Two long words</li>
<li>Two very long words</li>
</ul>
<li class="style4">//</li>
<li>Two long words</li>
<li class="style4">//</li>
<li>two words
<ul class="second-level-menu">
<li>single</li>
<li>single</li>
<li class="style4">//</li>
</ul>
<li class="style4">//</li>
<li>Eeeeeee</li>
</ul>
</div>

Why won't CSS hover effect cover only my dropdown menu?

In the first photo, my cursor is hovering over the slogan in the top right corner. If someone could tell me the adjustments I need to make so that my dropdown menu only comes down when I hover over it, it would be much appreciated.
HTML:
<ul class="dropdown">
<li>Menu</li>
<ul class="dropdownElements">
<li><a href="About.html"/>About</li>
<li><a href="Vintage.html"/>Vintage Products</li>
<li><a href="Antique.html"/>Antique Products</li>
<li><a href="Collectibles.html"/>Collectibles</li>
<li><a href="Contact.html"/>Contact Information</li>
</ul>
</ul>
CSS:
* {
margin: 0px;
padding: 0px;
}
div.header ul.dropdown {
position: absolute;
margin: auto;
list-style: none;
margin-left: 190px;
position: relative;
top: 40px;
}
div.header ul.dropdown li {
background-color: white;
height: 45px;
width: 135px;
line-height: 45px;
border-radius: 5px;
box-shadow: 1px 3px 5px black;
text-align: center
}
ul.dropdownElements li {
list-style: none;
}
div.header ul.dropdown li:hover {
background-color: #C5A06D;
transition: background linear 0.2s;
}
div.header ul ul {
visibility:hidden;
}
div.header ul:hover ul {
visibility:visible;
}
a:link {
text-decoration: none;
color: black;
}
See below. I have removed div.header at a few places because that element isn't in the HTML and stops the CSS from working.
Essential changes: list items of the top level menu positioned relative, submenu positioned absolute.
* {
margin: 0px;
padding: 0px;
}
ul.dropdown {
position: relative;
margin: auto;
list-style: none;
margin-left: 190px;
position: relative;
top: 40px;
}
div.header ul.dropdown li {
background-color: white;
height: 45px;
width: 135px;
line-height: 45px;
border-radius: 5px;
box-shadow: 1px 3px 5px black;
text-align: center
}
ul.dropdownElements {
display: none;
position: absolute;
top: 1em;
left: 0;
}
ul.dropdownElements li {
list-style: none;
}
div.header ul.dropdown li:hover {
background-color: #C5A06D;
transition: background linear 0.2s;
}
ul.dropdown li:hover ul.dropdownElements {
display: inline-block;
}
a:link {
text-decoration: none;
color: black;
}
<ul class="dropdown">
<li>Menu
<ul class="dropdownElements">
<li><a href="About.html" />About</li>
<li><a href="Vintage.html" />Vintage Products</li>
<li><a href="Antique.html" />Antique Products</li>
<li><a href="Collectibles.html" />Collectibles</li>
<li><a href="Contact.html" />Contact Information</li>
</ul>
</li>
</ul>

Nothing dropping down from drop down menu in navigation bar HTML CSS

I've looked through other questions but none seem to explain the problem I'm having. I want to create a drop down menu to an already existing navigation bar, and I think it's a problem with the way I've named the classes.
Here is my HTML code for the nav bar
<ul class="customMenu">
<li class="customList"><a class="menuActif" href="#">Home</a></li>
<li class="customList extendMenuClass"><a class="extendMenu" href="#">Cities</a></li>
<div class="extendedDiv">
Paris
Lyon
Toulouse
</div>
<li class="customList">Phrases</li>
<li class="customList">Bank Accounts</li>
<li class="customList">Important Notes</li>
<li class="customList">CAF</li>
<li class="customList" style="float:right"><a class="menuActif" onClick="verifDecon()">Déconnexion</a></li>
</ul>
And here is the CSS I have tried to implement:
.customMenu {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #00264d;
position: fixed;
top: 0;
width: 100%;
}
.customList {
float: left;
}
.customList a, .extendMenu{
font-family: Sans Serif;
font-size: 23px;
text-decoration: none;
text-align: center;
padding: 16px 17px;
display: block;
color: white;
}
.customList a:hover, .extendMenuClass:hover .extendMenu{
background-color: #00264d;
color: red;
}
.menuActif{
background-color: red;
color: red;
}
.menuActif:hover{
background-color: white;
color: #00264d;
}
.customList.extendMenuClass{
display: inline-block;
}
.extendedDiv{
display: none;
background-color: #00264d;
position: absolute;
min-width: 200px;
box-shadow: 10px 10px 10px 2px rgba(0,0,0,0.2);
z-index: 1;
}
.extendedDiv a{
display: block;
color: white;
padding: 15px 15px;
}
.extendedDiv a:hover{
color: red;
}
.extendMenuClass:hover .extendedDiv{
display: block;
}
I works otherwise, the menu just doesn't drop down. Can anyone help? Thanks a lot!
Your selector to show the menu on hover is .extendMenuClass:hover .extendedDiv, but .extendedDiv is not a child of .extendMenuClass. Updated that so that it is a child and that selector will work.
Then you need to remove overflow: hidden; from .customMenu since .extendedDiv will bleed below/outside of .customMenu and will be hidden if overflow is hidden.
.customMenu {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #00264d;
position: fixed;
top: 0;
width: 100%;
}
.customList {
float: left;
}
.customList a, .extendMenu{
font-family: Sans Serif;
font-size: 23px;
text-decoration: none;
text-align: center;
padding: 16px 17px;
display: block;
color: white;
}
.customList a:hover, .extendMenuClass:hover .extendMenu{
background-color: #00264d;
color: red;
}
.menuActif{
background-color: red;
color: red;
}
.menuActif:hover{
background-color: white;
color: #00264d;
}
.customList.extendMenuClass{
display: inline-block;
}
.extendedDiv{
display: none;
background-color: #00264d;
position: absolute;
min-width: 200px;
box-shadow: 10px 10px 10px 2px rgba(0,0,0,0.2);
z-index: 1;
}
.extendedDiv a{
display: block;
color: white;
padding: 15px 15px;
}
.extendedDiv a:hover{
color: red;
}
.extendMenuClass:hover .extendedDiv{
display: block;
}
<ul class="customMenu">
<li class="customList"><a class="menuActif" href="#">Home</a></li>
<li class="customList extendMenuClass"><a class="extendMenu" href="#">Cities</a>
<div class="extendedDiv">
Paris
Lyon
Toulouse
</div></li>
<li class="customList">Phrases</li>
<li class="customList">Bank Accounts</li>
<li class="customList">Important Notes</li>
<li class="customList">CAF</li>
<li class="customList" style="float:right"><a class="menuActif" onClick="verifDecon()">Déconnexion</a></li>
</ul>
Common syntax for navigation is nesting unordered lists inside other unordered lists.
so you'd set it up like:
<ul class="main-nav">
<li>1</li>
<li class="dropdown">2
<ul class="dropdown-list">
<li>2.1</li>
<li>2.2</li>
<li>2.3</li>
</li>
<li>3</li>
</ul>
It's a lot easier to keep parent and child elements in order.
I just set it up a little easier for you to follow and continually add items:
HTML:
<ul class="customMenu">
<li style="background:red;">Home</li>
<li class="extend">Cities
<ul class="dropdown">
<li>Paris</li>
<li>Lyon</li>
<li>Toulouse</li>
</ul>
</li>
<li>Phrases</li>
<li>Bank Accounts</li>
<li>Important Notes</li>
<li>CAF</li>
<li style="background: red; float: right;">Déconnexion</li>
</ul>
CSS:
ul.customMenu {
width: 100%;
background: #00264d;
}
ul.customMenu li {
display: inline-block;
}
ul.customMenu li a {
display: block;
font-size: 23px;
color: #fff;
text-decoration: none;
padding: 16px 17px;
}
ul.customMenu li a:hover {
color: red;
}
ul.customMenu li ul.dropdown {
display: none;
position: absolute;
top: 55px;
left: -5px;
background: red;
overflow: hidden;
}
ul.customMenu li ul.dropdown li a {
display: block;
width: 100%;
padding: 16px 20px;
}
ul.customMenu li ul.dropdown li a:hover {
color: #fff;
background: #cc0000 !important;
}
li.extend {
position: relative;
}
li.extend:hover ul.dropdown {
display: block !important;
}

How do I add curved corners to menu in css

I want to curve the corners in css in .second-level-menu.
I tried to add in .second-level-menu and in .second-level-menu > li:
border-radius: 0px 0px 8px 8px;
-moz-border-radius: 0px 0px 8px 8px;
-webkit-border-radius: 0px 0px 8px 8px;
/* Menu Styles */
.third-level-menu {
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li {
height: 30px;
background: #999999;
}
.third-level-menu > li:hover {
background: #CCCCCC;
}
.second-level-menu {
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu > li {
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li {
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.top-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu li:hover > ul {
/* On hover, display the next level's menu */
display: inline;
}
/* Menu Link Styles */
.top-level-menu a
/* Apply to all links inside the multi-level menu */
{
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
/* Make the link cover the entire list item-container */
display: block;
line-height: 30px;
}
.top-level-menu a:hover {
color: #000000;
}
<ul class="top-level-menu">
<li>About
</li>
<li>Services
</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago
</li>
<li>Los Angeles
</li>
<li>
New York
<ul class="third-level-menu">
<li>Information
</li>
<li>Book a Meeting
</li>
<li>Testimonials
</li>
<li>Jobs
</li>
</ul>
</li>
<li>Seattle
</li>
</ul>
</li>
<li>Contact
</li>
</ul>
It works with border-radius, you just can't see it because the overlapping li elements. Setting overflow:hidden to .second-level-menu will cause the radius to show.
/* Menu Styles */
.third-level-menu {
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li {
height: 30px;
background: #999999;
}
.third-level-menu > li:hover {
background: #CCCCCC;
}
.second-level-menu {
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
border-radius:0px 0px 8px 8px;
overflow:hidden;
}
.second-level-menu > li {
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li {
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.top-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu li:hover > ul {
/* On hover, display the next level's menu */
display: inline;
}
/* Menu Link Styles */
.top-level-menu a
/* Apply to all links inside the multi-level menu */
{
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
/* Make the link cover the entire list item-container */
display: block;
line-height: 30px;
}
.top-level-menu a:hover {
color: #000000;
}
<ul class="top-level-menu">
<li>About
</li>
<li>Services
</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago
</li>
<li>Los Angeles
</li>
<li>
New York
<ul class="third-level-menu">
<li>Information
</li>
<li>Book a Meeting
</li>
<li>Testimonials
</li>
<li>Jobs
</li>
</ul>
</li>
<li>Seattle
</li>
</ul>
</li>
<li>Contact
</li>
</ul>
If you add overflow: hidden, it partially solves problem, but then your third level menu is invisible. I would just add:
.second-level-menu > li:last-child {
border-radius: 0px 0px 8px 8px;
}
Demo: https://jsfiddle.net/cw8w6rwr/
(same for third level menu, if needed)
/* Menu Styles */
.third-level-menu {
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li {
height: 30px;
background: #999999;
}
.third-level-menu > li:hover {
background: #CCCCCC;
}
.second-level-menu {
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu > li {
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:last-child {
border-radius: 0px 0px 8px 8px;
}
.second-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li {
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.top-level-menu > li:hover {
background: #CCCCCC;
}
.top-level-menu li:hover > ul {
/* On hover, display the next level's menu */
display: inline;
}
/* Menu Link Styles */
.top-level-menu a
/* Apply to all links inside the multi-level menu */
{
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
/* Make the link cover the entire list item-container */
display: block;
line-height: 30px;
}
.top-level-menu a:hover {
color: #000000;
}
<ul class="top-level-menu">
<li>About
</li>
<li>Services
</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago
</li>
<li>Los Angeles
</li>
<li>
New York
<ul class="third-level-menu">
<li>Information
</li>
<li>Book a Meeting
</li>
<li>Testimonials
</li>
<li>Jobs
</li>
</ul>
</li>
<li>Seattle
</li>
</ul>
</li>
<li>Contact
</li>
</ul>