How to make this menu occupy all the remaining space's width? - css

There is a menu :
<div id="divmenuppal"> // this the menu
<ul class="dropdown">
<li class="menuppal">Administration
<ul>
<li>Artificial Turf</li>
<li>
Batting Cages
<ul>
<li>Indoor
<ul>
<li>Garden</li>
</ul>
</li>
<li>Outdoor</li>
</ul>
</li>
<li>Benches & Bleachers</li>
<li>Communication Devices</li>
<li>Dugouts</li>
<li>Fencing & Windscreen</li>
<li><hr></li>
<li>Floor Protectors</li>
<li>Foul Poles</li>
<li>Netting</li>
<li>Outdoor Furniture</li>
<li>Outdoor Signs</li>
<li><hr></li>
<li>Padding</li>
<li>Scoreboards</li>
<li>Shade Structures</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Structure
<ul>
<li>All-in-One Team Cart</li>
<li>Air & Electrical Reels</li>
<li>Field Drags</li>
<li>
Field Marking Equipment
<ul>
<li>Batter's Box Templates</li>
<li>Dryline Markers</li>
<li>Field Paint
<ul>
<li>Garden</li>
</ul>
</li>
<li>Field Sprayers</li>
<li>Stencils</li>
</ul>
</li>
<li>
Field Tarps
<ul>
<li>Area Tarps</li>
<li>Growth Covers / Protectors</li>
<li>Infield Tarps</li>
<li>Tarp Accessories</li>
</ul>
</li>
<li>Hand Tools</li>
<li>
Irrigation, Hoses, Nozzles
<ul>
<li>Hoses & Hose Reels</li>
<li>Irrigation</li>
<li>Nozzles</li>
</ul>
</li>
<li>Layout Tools</li>
<li>Moisture Removal</li>
<li><hr></li>
<li>Mound Fortification</li>
<li>Mowers & Stripers</li>
<li>Soil Management</li>
<li>Soil Amendments</li>
<li>Spreaders & Sweepers</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Exercice
<ul>
<li>
Baseball - Softball
<ul>
<li>Base Accessories</li>
<li>Bases & Home Plates</li>
<li>Game Accessories</li>
<li>Pitching Rubbers</li>
</ul>
</li>
<li>
Batting Practice Equipment
<ul>
<li>Backstops</li>
<li>Infield Screens</li>
<li>Jugs Pitching Machines</li>
<li>Turf Mats</li>
<li>Turf Protectors</li>
<li>Replacement Accessories</li>
</ul>
</li>
<li>
Batting Cages
<ul>
<li>Indoor</li>
<li>Outdoor</li>
</ul>
</li>
<li>
Portable Mounds
<ul>
<li>Batting Practice Mounds</li>
<li>Game Mounds</li>
<li>Practice Mounds</li>
</ul>
</li>
<li>
Football
<ul>
<li>First Down Markers</li>
<li>Football Accessories</li>
<li>Football Goalposts</li>
</ul>
</li>
<li>
Soccer
<ul>
<li>Soccer Goals</li>
<li>Soccer Accessories</li>
</ul>
</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Contribuables et biens
<ul>
<li>Ladders & Sticks</li>
<li>Hurdles</li>
<li>Training Accessories</li>
<li>Smart-Cart Training System</li>
<li>Smart-Hurdle Collection</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Recettes
<ul>
<li>Field Design</li>
<li>Turf Management</li>
<li>Training</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Edition
<ul>
<li>Field Design</li>
<li>Turf Management</li>
<li>Training</li>
<li> - VIEW ALL - </li>
</ul>
</li>
<li class="menuppal">Outils
<ul>
<li>Field Design</li>
<li>Turf Management</li>
<li>Training</li>
<li> - VIEW ALL - </li>
</ul>
</li>
</ul>
</div>
<div class="breadcrumbs" style="clear:left;"> // this is the breadcrumbs
<div class="container-fluid">
<ul class="bread">
<li>Accueil</li><li>Gestion des contribuables</li><li><a>Fiche d'un contribuable</a></li>
</ul>
<ul class="bread pull-right">
<li style="color: #000;padding: 5px;font-size: 11px;font-weight: bold;">Fiche d'un contribuable</li>
</ul>
</div>
</div>
The css of the menu :
* {
margin: 0;
padding: 0;
}
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
a {
text-decoration: none;
font-size: 11px;
font-weight: 100;
width: 100%;
box-sizing: border-box;
}
ul {
list-style: none;
}
ul.dropdown ul {
width: 220px;
visibility: hidden;
position: absolute;
background-color: #40617C;
}
ul.dropdown li:not(.menuppal):not(:first-child):not(:last-child)
{
margin-top: 8px;
margin-bottom: 8px;
}
hr {
margin-left: 6px;
margin-right: 8px;
border-top: 0;
}
/*
LEVEL ONE : MAIN MENU
*/
ul.dropdown {
position: relative;
}
ul.dropdown li.menuppal {
float: left;
zoom: 1;
background: #000 url(../images/menuLight.png) repeat-x top left;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-left: 1px solid #222;
}
ul.dropdown li.menuppal a {
display: block;
padding: 4px 8px;
color: #000000;
}
/* Doesn't work in IE */
ul.dropdown li.menuppal:hover {
background: #ccc url('../images/menuDark.png') repeat-x 50% 50%;
position: relative;
}
/*
FIN LEVEL ONE
*/
/*
LEVEL TWO
*/
ul.dropdown ul {
top: 100%;
left: 0;
}
ul.dropdown ul li {
float: none;
position: relative;
}
/* IE 6 & 7 Needs Inline Block */
ul.dropdown li.menuppal ul li a {
border-right: none;
color: #FFF;
display: inline-block;
}
ul.dropdown li.menuppal ul li a:hover {
background: #07243a;
}
ul.dropdown li.menuppal ul li a:visited {
word-break: break-all;
}
/*
LEVEL THREE
*/
ul.dropdown ul ul {
left: 100%;
top:0!important;
}
/*
LEVEL FOUR
*/
ul.dropdown ul ul ul {
left: 100%;
top:0!important;
}
ul.dropdown li:hover > ul {
visibility: visible;
}
At runtime the menu is not occupying all the horizontal space :
So how to make the menu fill the remaining space like in this image :

ul.dropdown {
background: #000 url(../images/menuLight.png) repeat-x top left;
}

Use flex layout. I add following code to the bottom of your CSS and it did the trick:
#divmenuppal > .dropdown {
display: flex;
}
.dropdown .menuppal:last-child {
flex-grow: 1;
}
http://jsfiddle.net/w2n79nsy/

ok I found it from #SunilDalal's answer :
ul.dropdown {
position: relative;
float: left;
width: 100%;
background: #000 url('menuLight.png') repeat-x top left;
}

Related

CSS - align drop-down menus to the left, middle, and right

I have 3 drop-down menus under nav, and I want to align them left, middle, and right. The left and right alignment are working using float, but I'm having difficulty to align a drop-down menu to the middle. Please see the css selector
.inline-menu.middle-menu at https://jsfiddle.net/xv51vkc7/.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Title</title>
<link rel="stylesheet" type="text/css" href="css/theme_1.css">
</head>
<body>
<nav>
<ul class="inline-menu left-menu">
<li>Left-A
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
<li>Left-B
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
</ul>
<ul class="inline-menu middle-menu">
<li>Middle-A
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
<li>Middle-B
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
</ul>
<ul class="inline-menu right-menu">
<li>Right-A
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
<li>Right-B
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
</ul>
</nav>
</body>
</html>
body{
background-color: #eee;
padding: 0;
}
.inline-menu,
.inline-menu ul{
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li{
display: inline-block;
padding-right: 25px;
background-color: yellow;
position: relative;
}
.inline-menu a{
text-decoration: none;
}
.inline-menu > li > ul{
display: none;
position: absolute;
background-color: green;
}
.inline-menu > li:hover > ul{
display: block;
width: 100%; /* same width as parent */
}
.inline-menu.left-menu{
float: left;
}
.inline-menu.right-menu{
float: right;
}
.inline-menu.middle-menu{
}
Flexbox can do that:
body {
background-color: #eee;
padding: 0;
}
nav {
display: flex;
justify-content: space-between;
}
.inline-menu,
.inline-menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li {
display: inline-block;
padding-right: 25px;
background-color: yellow;
position: relative;
}
.inline-menu a {
text-decoration: none;
}
.inline-menu > li > ul {
display: none;
position: absolute;
background-color: green;
}
.inline-menu > li:hover > ul {
display: block;
width: 100%;
/* same width as parent */
}
.inline-menu.left-menu {
float: left;
}
.inline-menu.right-menu {
float: right;
}
.inline-menu.middle-menu {
float: left;
}
<nav>
<ul class="inline-menu left-menu">
<li>Left-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>Left-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
<ul class="inline-menu middle-menu">
<li>Middle-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>Middle-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
<ul class="inline-menu right-menu">
<li>Right-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>Right-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
</nav>

How to create an absolutely positioned submenu which appears on css hover

I have a menu which needs to expand to show the child elements on hover. According to the design the expanded child ul needs to expand across the full width of the page so needs to be absolutely positioned in order to break out from the width of the parent li.
The problem is that I need the child ul to remain visible as you hover over it. Because it is absolutely positioned it no longer contained by the parent li, so as soon as my mouse moves off that it disappears.
If I change the parent li to position:relative the ul remains visible when the mouse moves over it, but the child ul no longer fills 100% width of the page.
Here is a fiddle to demonstrate:
https://jsfiddle.net/sx2aouht/12/
Here is abbreviated markup (full code on the fiddle link above):
<nav class="priority-nav">
<ul class="menu">
<li class="first expanded active-trail active menu-mlid-178 help">Help & Advice
<ul class="menu">
<li class="first leaf menu-mlid-526">Find your local services</li>
<li class="leaf menu-mlid-528">Join CarerSmart</li>
<li class="leaf menu-mlid-527">Join our online community</li>
</ul>
</li>
</ul>
</nav>
Here is the css:
.priority-nav ul li {
//if this is uncommented the ul will remain visible when
//the mouse is over it, but the ul will not fill the page 100%
//position: relative;
float: left;
padding: 0 10px;
list-style-type: none;
}
.priority-nav ul li ul {
display: none;
position: absolute;
top: 40px;
left: 0;
background-color: red;
width: 100%;
padding: 50px 130px;
}
.priority-nav ul li:hover ul {
display: block;
}
The menu already stays open when you hover the submenu, the problem is that when the mouse goes down to the submenu, it leaves the hovered li element, in order to avoid this make sure that when the mouse enters the submenu, it will not leave the main li you hover, the submenu is in the li item, so hovering it is considered hovering the main li.
You just have to avoid leaving the main li until you enter the submenu, I used some padding in your example:
.priority-nav ul li {
//if this is uncommented the ul will remain visible when
//the mouse is over it, but the ul will not fill the page 100%
//position: relative;
float: left;
padding: 0 10px 5px;
list-style-type: none;
}
.priority-nav ul li ul {
display: none;
position: absolute;
top: 35px;
left: 0;
background-color: red;
width: 100%;
padding: 50px 130px;
}
.priority-nav ul li:hover ul {
display: block;
}
<nav class="priority-nav">
<ul class="menu"><li class="first expanded active-trail active menu-mlid-178 help">Help & Advice<ul class="menu"><li class="first leaf menu-mlid-526">Find your local services</li>
<li class="leaf menu-mlid-528">Join CarerSmart</li>
<li class="leaf menu-mlid-527">Join our online community</li>
<li class="leaf menu-mlid-530">Help and advice topic 4</li>
<li class="leaf menu-mlid-531">Help and advice topic 5</li>
<li class="leaf menu-mlid-532">Help and advice topic 6</li>
<li class="leaf menu-mlid-533">Help and advice topic 7</li>
<li class="leaf menu-mlid-534">Help and advice topic 8</li>
<li class="last leaf menu-mlid-535">Help and advice topic 9</li>
</ul></li>
<li class="expanded menu-mlid-184 community">Online Community<ul class="menu"><li class="first leaf menu-mlid-536">Discussion board</li>
<li class="last leaf menu-mlid-537">Chat</li>
</ul></li>
<li class="last expanded menu-mlid-176 get-involved">Get Involved<ul class="menu"><li class="first leaf menu-mlid-529">Donate</li>
<li class="leaf menu-mlid-538">Events</li>
<li class="leaf menu-mlid-539">Volunteer</li>
<li class="last leaf menu-mlid-540">Corporate opportunities</li>
</ul></li>
<li class="more"><span>More</span></li>
</ul>
</nav>
If the submenu is to be 100% width of the page but the top-level menu is not then we can still position the submenu in relation to the parent menu and not the li.
.priority-nav >.menu {
position: relative;
}
But we size the submenu to the width of the page with viewport units.
.priority-nav ul li ul {
display: none;
position: absolute;
top:100%;
left: 0;
background-color: red;
width: 100vw;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.cf:before,
.cf:after {
content: " ";
display: table;
/* clearfix */
}
.cf:after {
clear: both;
}
.priority-nav {
position: relative;
width: 70%;
}
.priority-nav > .menu {
background: #c0ffee;
}
.priority-nav ul li {
float: left;
padding: 0 10px;
list-style-type: none;
padding: 10px;
}
.priority-nav ul li ul {
display: none;
position: absolute;
top: 100%;
left: 0;
background-color: red;
width: 100vw;
}
.priority-nav ul li:hover ul {
display: block;
}
<nav class="priority-nav">
<ul class="menu cf">
<li class="first expanded active-trail active menu-mlid-178 help">Help & Advice
<ul class="menu">
<li class="first leaf menu-mlid-526">Find your local services
</li>
<li class="leaf menu-mlid-528">Join CarerSmart
</li>
<li class="leaf menu-mlid-527">Join our online community
</li>
<li class="leaf menu-mlid-530">Help and advice topic 4
</li>
<li class="leaf menu-mlid-531">Help and advice topic 5
</li>
<li class="leaf menu-mlid-532">Help and advice topic 6
</li>
<li class="leaf menu-mlid-533">Help and advice topic 7
</li>
<li class="leaf menu-mlid-534">Help and advice topic 8
</li>
<li class="last leaf menu-mlid-535">Help and advice topic 9
</li>
</ul>
</li>
<li class="expanded menu-mlid-184 community">Online Community
<ul class="menu">
<li class="first leaf menu-mlid-536">Discussion board
</li>
<li class="last leaf menu-mlid-537">Chat
</li>
</ul>
</li>
<li class="last expanded menu-mlid-176 get-involved">Get Involved
<ul class="menu">
<li class="first leaf menu-mlid-529">Donate
</li>
<li class="leaf menu-mlid-538">Events
</li>
<li class="leaf menu-mlid-539">Volunteer
</li>
<li class="last leaf menu-mlid-540">Corporate opportunities
</li>
</ul>
</li>
<li class="more"><span>More</span>
</li>
</ul>
</nav>

Right aligning last nav menu pop up with CSS

I'm looking to right align the "pop-up" menu of my nav structure to the right edge of the div. Currently, it is "popping out" of the div. Any suggestions on how to accomplish this?
.main-navigation {
background-color: #2f9fa8;
}
.subMenu li:hover > a {
color: #e3d174;
text-decoration: underline;
}
#GeneralInfo {
width: 160px;
padding-top: 5px;
padding-left: 20px;
}
#Registration {
width: 200px;
padding-top: 5px;
padding-left: 20px;
}
#ScientificPrograms {
width: 175px;
padding-top: 5px;
padding-left: 20px;
}
#SpecialEvents {
width: 110px;
padding-top: 5px;
padding-left: 20px;
}
#Careers {
width: 70px;
padding-top: 5px;
padding-left: 20px;
}
#Exhibits {
width: 90px;
padding-top: 5px;
padding-left: 20px;
}
.subMenu {
width: 200px;
}
#navMenu ul,
#navMenu {
list-style-type: none;
margin: 0;
padding: 0;
}
.nav > li > a {
display: block;
height: 100%;
color: #FFFFFF;
text-decoration: none;
padding: 0;
font-size: 14px;
font-weight: 800;
outline: none;
}
.nav > li > a:hover {
display: block;
height: 100%;
padding: 0;
color: #FFFFFF;
text-decoration: none;
background: #2f9fa8;
}
.nav > li {
padding: 0;
float: left;
height: 30px;
font-family: Arial, sans-serif;
font-size: 14px;
background-color: #2f9fa8;
}
.nav li {
position: relative;
}
.nav li > ul {
position: absolute;
display: none;
border-bottom: 0;
z-index: 9999;
}
.nav li > ul > li > a {
text-decoration: none;
color: #FFFFFF;
font-weight: 600;
display: block;
background: #2f9fa8;
text-shadow: none;
padding: 5px 3px 5px 10px;
text-indent: -7px;
}
.nav li:hover > ul {
display: block;
}
<nav class="main-navigation">
<ul id="navMenu" class="nav">
<li id="GeneralInfo"><a class="gradient" href="#">General Information</a>
<ul class="subMenu" id="sub-GeneralInfo">
<li><a href='#'>Annual Meeting</a>
</li>
<li><a href='#'>San Diego, CA</a>
</li>
<li><a href='#'>Supporters</a>
</li>
<li><a href='#'>Just for the Media</a>
</li>
<li><a href='#'>Volunteer</a>
</li>
<li><a href='#'>Awards and Fellowships</a>
</li>
<li><a href='#'>FAQs</a>
</li>
<li><a href='#'>Forms</a>
</li>
<li><a href='#'>Events and Maps</a>
</li>
<li><a href='#'>Meeting Requests</a>
</li>
<li><a href='#'>Visa Information</a>
</li>
<li><a href='#'>Transportation</a>
</li>
<li><a href='#'>Ride Share Program</a>
</li>
<li><a href='#'>Restaurants</a>
</li>
<li class='last'><a href='#'>Top Reasons to Attend</a>
</li>
</ul>
</li>
<li id="Registration"><a class="gradient" href="#">Registration & Housing</a>
<ul class="subMenu" id="sub-Registration">
<li><a href='#'>Online Registration</a>
</li>
<li><a href='#'>Registration Information</a>
</li>
<li><a href='#'>Housing Reservations</a>
</li>
<li class='last'><a href='#'>Room Share Program</a>
</li>
</ul>
</li>
<li id="ScientificPrograms"><a class="gradient" href="#">Scientific Programs</a>
<ul class="subMenu" id="sub-ScientificPrograms">
<!--<li><a href='#'>Submit a Session Proposal</a></li>-->
<li><a href='#'>Submit an Abstract</a>
</li>
<li><a href='#'>Mobile Event App</a>
</li>
<!--<li><a href='#'>Scientific Session Index</a></li>-->
<!--<li><a href='#'>Abstract Author Index</a></li>-->
<!--<li><a href='#'>Abstract Keyword Index</a></li>-->
<li><a href='#'>Continuing Education</a>
</li>
<li><a href='#'>Continuing Medical Education</a>
</li>
<li><a href='#'>Scientific Sessions</a>
</li>
<li><a href='#'>Thematic Approach</a>
</li>
<!--<li><a href='#'>Scientific ePosters</a></li>-->
<li class='last'><a href='#'>Presentation Instructions</a>
</li>
</ul>
</li>
<li id="SpecialEvents"><a class="gradient" href="#">Special Events</a>
<ul class="subMenu" id="sub-SpecialEvents">
<li><a href='#'>Outreach</a>
</li>
<li><a href='#'>Featured Sessions</a>
</li>
<li><a href='#'>Social Events</a>
</li>
<li><a href='#'>Student and Postdoc Scholar Events</a>
</li>
<li><a href='#'>Satellite Meetings</a>
</li>
<li><a href='#'>Meeting Requests</a>
</li>
<li class='last'><a href='#'>Virtual Global Gallery Posters</a>
</li>
</ul>
</li>
<li id="Careers"><a class="gradient" href="#">Careers</a>
<ul class="subMenu" id="sub-Careers">
<li><a href='#'>Career Sessions</a>
</li>
<li><a href='#'>Career Resources and Development Services</a>
</li>
<li class='last'><a href='#'>Job Bank</a>
</li>
</ul>
</li>
<li id="Exhibits"><a class="gradient" href="#">Exhibits</a>
<ul class="subMenu" id="sub-Exhibits">
<li><a href='#'>ToxExpo</a>
</li>
<li><a href='#'>Exhibitor Listing</a>
</li>
<li><a href='#'>Exhibitor-Hosted Session Application</a>
</li>
<li><a href='#'>Exhibitor-Hosted Sessions</a>
</li>
<li><a href='#'>Support Opportunities</a>
</li>
<li class='last'><a href='#'>Supporter Listing</a>
</li>
</ul>
</li>
</ul>
</nav>
You can fint it also in codepen
If you are looking to right align the popup menu .nav li ul to the container "trigger" menu element then you should simply add right: 0; to .nav li > ul
Like:
.nav li > ul {
position: absolute;
display: none;
border-bottom: 0;
right: 0;
z-index: 9999;
}

CSS Space Between Submenu Items

I am trying to lessen the vertical space between items in the submenu of my drop down navigation bar. You can see what it currently looks like at http://www.mirandabee.com
I am trying to reduce the space vertically, but can't figure it out.
Here is my HTML for it:
<ul id ="nav">
<li><a href="http://www.mirandabee.com/search/label/About%20Me#.UuQfD-Io6Rs">About Me
<ul>
<li>About Me</li>
<li>Photo Album</li>
</ul>
</a></li>
<li><a href="http://www.mirandabee.com/search/label/Blog%20Series#.UuPc3uIo6Rs1">Blog Series
<ul>
<li>Guest Post Monday</li>
<li>Infographic Monday</li>
<li>What I Wore Wednesday</li>
<li>Fun Friday Link Party</li>
</ul>
</a></li>
<li><a href="http://www.mirandabee.com/search/label/Freebies#.UhDj0D92XiM">Freebies
<ul>
<li>Giveaways</li>
<li>Printables</li>
</ul>
</a></li>
<li><a href="http://www.mirandabee.com/search/label/Recipes#.UuPyGOIo6Rt">Recipes
<ul>
<li>All Recipes</li>
<li>Appetizers</li>
<li>Snacks</li>
<li>Main Dishes</li>
<li>Sides</li>
<li>Drinks</li>
<li>Desserts</li>
<li>Other Recipes</li>
</ul>
</a></li>
<li><a href="http://www.mirandabee.com/search/label/Projects%20%26%20Crafts#.UuP03OIo6Rt">Projects
<ul>
<li>For the Home</li>
<li>Kids & Family</li>
<li>Travel Solutions</li>
<li>Gift Ideas</li>
<li>Other</li>
</ul>
</a></li>
<li><a href="http://www.mirandabee.com/search/label/Organize%20Your%20Life#.UuP2yuIo6Rt">Organization
<ul>
<li>One Space at a Time</li>
</ul>
</a></li></ul>
CSS:
/* ----- NAVMENU ----- */
#nav, #nav ul {
padding: 0px;
margin: 0;
z-index: 999;
margin-top: -80px;
margin-left: 100px;
list-style: none;
color: #007581;
}
#nav a {
display: block;
width: 6.5em;
}
#nav li {
float: left;
width: 6.5em;
font-size:18px;
color: #ff6962
}
#nav li ul {
position: absolute;
width: 6em;
font-size: 5px;
left: -999em;
}
#nav li:hover ul {
left: auto;
width: 7em;
font-size:18px;
color: #ff6962;
margin-left: -2px;
padding-top:-112px;
}
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
#nav li:hover ul, #nav li.sfhover ul {
left: auto;
}
Keep in mind that I am very much a beginner, but I would appreciate any help I can get. Thanks so much!
Your HTML is totally broken. You have
<a><ul><li><a>...</a></li></ul></a>
you cannot have anchors inside anchors like that. Your css also doesn't make much sense. You've got position: absolute, but no position: relative anywhere else, so ALL of the nested <ul>'s are going to be in the wrong place.
Your HTML structure is bad. I'm sorry to say that. But here I try to fix it for you.
Fiddle
HTML:
<ul id="nav">
<li>
About Me
<ul>
<li>About Me</li>
<li>Photo Album</li>
</ul>
</li>
<li>
Blog Series
<ul>
<li>Guest Post Monday</li>
<li>Infographic Monday</li>
<li>What I Wore Wednesday</li>
<li>Fun Friday Link Party</li>
</ul>
</li>
<li>Freebies
<ul>
<li>Giveaways</li>
<li>Printables</li>
</ul>
</li>
<li>Recipes
<ul>
<li>All Recipes</li>
<li>Appetizers</li>
<li>Snacks</li>
<li>Main Dishes</li>
<li>Sides</li>
<li>Drinks</li>
<li>Desserts</li>
<li>Other Recipes</li>
</ul>
</li>
<li>Projects
<ul>
<li>For the Home</li>
<li>Kids & Family</li>
<li>Travel Solutions</li>
<li>Gift Ideas</li>
<li>Other</li>
</ul>
</li>
<li>Organization
<ul>
<li>One Space at a Time</li>
</ul>
</li>
</ul>
CSS:
/* ----- NAVMENU ----- */
#nav, #nav ul {
padding: 0px;
margin: 0;
z-index: 999;
margin-top: 0px;
margin-left: 100px;
list-style: none;
color: #007581;
}
#nav a {
display: block;
width: 6.5em;
}
#nav li {
float: left;
width: 6.5em;
font-size:18px;
color: #ff6962
}
#nav li ul {
position: absolute;
width: 6em;
font-size: 5px;
left: -999em;
}
#nav li:hover ul {
left: auto;
width: 7em;
font-size:18px;
color: #ff6962;
margin-left: -2px;
padding-top:-112px;
}
#nav li:hover ul, #nav li.sfhover ul {
left: auto;
}
I hope it will help you on solving this problem.. :)

Styling a three-level unordered list

I have a 3-level deep, unordered list I'm styling to create a drop-down menu to extend this 2-level simple drop-down menu. The CSS is as follows:
#CHARSET "ISO-8859-1";
/* menu styles */
/* Top-level (Styles Works) */
#jsddm
{ margin: 0;
padding: 0}
#jsddm li
{ float: left;
list-style: none;
font: 12px Tahoma, Arial;}
#jsddm li a
{ display: block;
/*background: #324143; Old Style*/
background: -webkit-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(204,204,204,1) 100%); /* Chrome10+,Safari5.1+ */;
padding: 5px 12px;
text-decoration: none;
border-right: 1px solid white;
width: 70px;
/*color: #EAFFED; Default color*/
color: #000099;
white-space: nowrap;}
#jsddm li a:hover
{ background: #24313C}
/* 2nd-level (Styles Works) */
#jsddm li ul
{ margin: 0;
padding: 0;
position: absolute;
visibility: visible;
border-top: 1px solid white}
#jsddm li ul li
{ float: none;
display: inline}
#jsddm li ul li a
{ width: auto;
background: #dfeffc;
color: #24313C}
#jsddm li ul li a:hover
{ background: #5c9ccc}
/* 3rd-level (Doesn't apply styles) */
#jsddm li ul li ul
{ margin: 0;
padding: 0;
position: absolute;
visibility: hidden;
border-top: 2px solid green}
The styling works for the first two levels, but not for the 3rd, I'm not sure if I have the syntax correct or if there's something else I'm missing. The html is as follows:
<div id="dropDownDiv">
<ul id="jsddm">
<li><a class="btn" href="#">Top Item 1</a>
<ul>
<li><a id="" class="btn" href="#">2nd Level Item 1</a></li>
<li>2nd Level Item 2</li>
</ul>
</li>
<li><a class="btn" href="#">Top Item 2</a>
<ul>
<li><a id="" class="btn hide" href="#">2nd Level Item 1</a></li>
<ul>
<li><a id="" class="btn hide" href="#">3rd Level Item 1</a></li>
<li><a id="" class="btn" href="#">3rd Level Item 1</a></li>
</ul>
<li><a id="" class="btn" href="#">2nd Level Item 1</a></li>
</ul>
</li>
</ul>
</div>
Any suggestions are appreciated.
UPDATE:
Thanks for loaning me your eyes Gareth. Corrected html:
<ul id="jsddm">
<li><a class="btn" href="#">Top Item 1</a>
<ul>
<li><a id="" class="btn" href="#">2nd Level Item 1</a></li>
<li>2nd Level Item 2</li>
</ul>
</li>
<li><a class="btn" href="#">Top Item 2</a>
<ul>
<li><a id="" class="btn hide" href="#">2nd Level Item 1</a>
<ul>
<li><a id="" class="btn hide" href="#">3rd Level Item 1</a></li>
<li><a id="" class="btn" href="#">3rd Level Item 1</a></li>
</ul>
</li>
<li><a id="" class="btn" href="#">2nd Level Item 1</a></li>
</ul>
</li>
</ul>
Your third level ul is not contained within an li. That might be causing your problem.

Resources