Trouble with second nested menu - html

I'm having an issue with adding a child menu to my first drop down menu. Basically this is the structure I am going for:
<ul id="nav" class="sixteen columns">
<li>Home</li>
<li>Portfolio
<ul>
<li>Asia
<ul>
<li>Korea</li>
<li>China</li>
<li>Japan</li>
</ul>
</li>
<li>Europe
<ul>
<li>France</li>
<li>Germany</li>
<li>Italy</li>
</ul>
</li>
</ul>
</li>
</ul>
And here is the CSS I am using:
#nav {
font-family: lanenar;
font-size: 1.2em;
z-index: 999;
position: relative;
}
#nav ul ul {
display: none;
}
#nav ul li:hover > ul {
display: block;
}
#nav ul {
padding: 0;
list-style: none;
position: relative;
display: inline-block;
background: #111;
}
#nav ul li {
float: left;
}
#nav ul li a {
padding: 5px 10px 5px 10px;
display: block;
color: #FFF;
text-decoration: none;
}
#nav ul li:hover {
background: #666;
}
#nav ul li:hover a {
color: #FFF;
}
#nav ul li:hover > ul { margin: 0px; padding: 0px;}
#nav ul li:hover > ul li { float: none; display: block;}
#nav ul li:hover > ul li a { color: #FFF; min-width: 150px;}
#nav ul li:hover > ul li a:hover {color: #FFF;}
#nav ul li {
position: relative;
}
#nav ul li ul {
position: absolute;
top: 28px;
left: 0px;
}
I am having a hard time figuring out what CSS I need to add to have the 2nd nested menu appear to the right when you mouseover Asia or Europe?
Any help would be much appreciated!

HTML
<ul id="nav" class="sixteen columns">
<li>Home
</li>
<li>Portfolio
<ul>
<li>Asia
<ul>
<li>Korea</li>
<li>China</li>
<li>Japan</li>
</ul>
</li>
<li>Europe
<ul>
<li>France</li>
<li>Germany</li>
<li>Italy</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
#nav {
width:800px;
margin:30px 50px;
padding: 0;
float:left;
}
#nav li {
list-style: none;
float: left;
padding:0 10px;
background-color:#367FB3;
color:white;
}
#nav li a:hover {
background-color:#52baff;
color:#fff;
}
//daf adf
/*--temp--*/
#nav ul ul li {
clear:left;
}
#nav ul ul {
position:absolute;
left:14em;
top:0;
}
#nav ul ul li a {
display:block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
/*--end temp--*/
#nav li a {
display: block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
#nav a:hover {
color:#367FB3;
}
#nav a:active {
color:#367FB3;
}
#nav li ul {
display: none;
width: 14em;
/* Width to help Opera out */
background-color:transparent;
z-index:666;
}
#nav li:hover ul, #nav li.hover ul {
display: block;
position: absolute;
margin:0px -10px;
padding:0px;
}
#nav li:hover ul ul {
display:none;
}
#nav li ul li:hover ul {
display:block
}
#nav li:hover li, #nav li.hover li {
float: none;
line-height:30px;
}
#nav li:hover li a, #nav li.hover li a {
background-color:#367FB3;
color:#fff;
font-size:13px;
font-family:"Lato" !important;
}
#nav li li a:hover {
background-color:#52baff;
color:#fff;
}
Working Fiddle
Added this to the Updated Fiddle as per SurjithSM suggestion
#nav li {
position: relative;
}
Updated Fiddle

Related

Wordpress Dropdown Navigation menu

I need help with my dropdown menu.
What I want to achieve is to hide my sub menu as well as my sub child menu. Also, I want to the sub list item to only show only if I hover to the list items that I want.
Thank you in advance. Your help very much appreciated!
This is my CSS:
#access ul ul a { color: #fff; }
#access { position:relative; float:left; height:19px; margin-left:15px; }
#access ul {list-style-type:none; margin:0px; padding:0px;}
#access li {float: left;position: relative; }
#access a { height:19px; display: block; padding:3px 15px 0 15px; text- decoration: none;font-size: 14px; font-family:'LeagueGothicRegular'; color: #ffffff;}
#access ul ul { display: none; float: left; margin: 0; position: absolute; top: 10px; left: 0; width: 150px; z-index: 99999; }
#access ul ul ul { left: 100%; top: 0; }
#access ul ul a {
margin-top:1px;
background: #000000;
color: #ffffff;
font-size: 14px;
font-weight: normal;
height: 19px;
line-height: 1.4em;
padding:2px 15px 0 15px;
width: 157px;
text-decoration: none; font-family:'LeagueGothicRegular', Abadi MT Condensed , Charcoal, sans-serif; color: #ffffff;}
#access li a:hover { color: #ed1c24; }
/* I believe HERE is the problem */
#access li:hover ul { display: block; color: #ffffff;}
#access a:focus {color: #ed1c24;}
#access .current_page_ancestor > a { color:#ed1c24;}
I managed to solve my problem. This worked for me.
#access ul li:hover > ul {
display: block;
}
The line you mention does in fact affect your menu. Don't use display:block unless you want to show it, and position:relative also may throw off the positioning.
This is a fairly simplistic solution for it. You will have to change the classes to work with the ones that wordpress uses. I don't have a copy which I can use at the moment to be more helpful.
ul.menu {
background:#222;
color:#FFF;
padding:0;
margin:0;
}
ul.menu a {
text-decoration:none;
display:inline-block;
padding: 10px;
color:inherit;
}
ul.menu li {
display:inline-block;
position:relative;
}
ul.menu li:hover {
background:#777;
color:#00F;
}
ul.menu > li.submenu > ul.menu {
display:none;
position:absolute;
top:100%;
left:0;
}
/* For submenus put them on the right side */
ul.menu > li.submenu > ul.menu ul.menu {
display:none;
position:absolute;
top:0;
left:100%;
}
ul.menu > li.submenu:hover ul.menu,
ul.menu > li.submenu li.submenu:hover ul.menu {
display:block;
}
<ul class="menu">
<li class="submenu">Test
<ul class="menu">
<li class="submenu">Test 2
<ul class="menu">
<li>Test 3
</ul>
</li>
</ul>
</li>
</ul>

submenu in one line with css

I want to make navigation menu like the picture above with hover on Menu. This is my sample code for the navigation menu.
<div id="menu">
<ul>
<li>Menu1
<ul class="submenu">
<li>Menu1Sub1</li>
<li>Menu1Sub2</li>
<li>Menu1Sub3</li>
<li>Menu1Sub4</li>
</ul>
</li>
<li>Menu2
<ul class="submenu">
<li>Menu2Sub1</li>
<li>Menu2Sub2</li>
<li>Menu2Sub3</li>
</ul>
</li>
...
</ul>
</div>
Submenu position are in a line and I also want Submenu position to be exactly same for each Menu if possible.
How to do this with css?
this is what I tried so far not working as I intended.
#menu {
text-decoration:none;
}
#menu li {
line-height:20px;
float:left;
}
#menu li > ul {
display: none;
}
#menu li:hover > ul {
display: block;
}
#menu li ul li {
line-height:13px;
float:left;
position:relative;
}
Any help would be very appreciated.
try this code:
#menu {
position: relative;
background-color: black;
text-decoration:none;
}
#menu li {
background-color: green;
padding: 10px;
height: 30px;
list-style: none;
line-height:30px;
float:left;
}
#menu li > ul {
display: none;
}
#menu > ul > li {
border: 2px solid white;
}
#menu > ul > li:hover {
border: 2px solid black;
}
#menu li:hover > ul {
display: block;
position: absolute;
top: 54px;
left: 0;
}
#menu li ul li {
float:left;
position:relative;
}
DEMO jsfiddle

how to put a single navigation item on the right

good day i need help to separate my navigation bar the WELCOME ADMIN should be on the right side here is my code.
HTML
<div id="menu">
<ul>
<li>item1</li>
<li>item1<ul>
<li>item1</li>
<li>item1</li>
<li>item1</li></ul>
</li>
<li>item1</li>
<li>item1<ul>
<li>item1</li>
<li>item1</li>
<li>item1</li></ul>
</li>
<li class="right"><a href="#" >Welcome Admin</a>
<ul>
<li>Subitem One</li>
li>Subitem Two</li>
<li>Subitem Three</li>
</ul>
</li>
</ul>
</nav>
CSS
#menu {
background:#000;
width:100%;
margin-top:0px;
height:40px;
border-radius: 3px;
}
#menu ul ul {
display: none;
}
#menu ul li:hover > ul {
display: block;
}
#menu ul {
background: #000
padding: 0px;
border-radius: 5px;
float:left;
list-style: none;
margin-top:-20px;
position: relative;
display: inline-table;
}
}
#menu ul:after {
content: ""; clear: both; display: block;
}
#menu ul li {
float: left;
}
#menu ul li:hover {
color:#fff;
}
#menu ul li:hover a {
background:#fff;
color: #000;
}
#menu ul li a {
display: block; margin-top:20px;
padding:10px 5px;
color: #FFF; text-decoration: none;
}
#menu ul ul {
background: #fff;
padding:0;
position: absolute;
top: 80px;
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
}
#menu ul ul li {
float: none;
position: relative;
}
#menu ul ul li a {
padding: 15px 40px;
color: #fff;
}
#menu ul ul li a:hover {
background: #000;
color:#fff;
}
thankyou for your answers badly need your help for this projects thankyou for those who will answer
You need to specify the width of the ul as 100% otherwise the float:left on it collapses the uls width.
The just float the last li to the right.
JSFiddle Demo
CSS
#menu {
background:#000;
width:100%;
margin-top:0px;
height:40px;
border-radius: 3px;
}
#menu ul ul {
display: none;
}
#menu ul li:hover > ul {
display: block;
}
#menu ul {
background: #000;
width:100%;
padding: 0px;
border-radius: 5px;
float:left;
list-style: none;
margin-top:-20px;
position: relative;
display: inline-table;
}
#menu ul:after {
content: ""; clear: both; display: block;
}
#menu ul li {
float: left;
}
#menu ul li:hover {
color:#fff;
}
#menu ul li:hover a {
background:#fff;
color: #000;
}
#menu ul li a {
display: block; margin-top:20px;
padding:10px 5px;
color: #FFF; text-decoration: none;
}
#menu ul ul {
background: #fff;
padding:0;
position: absolute;
top: 80px;
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
}
#menu ul ul li {
float: none;
position: relative;
}
#menu ul ul li a {
padding: 15px 40px;
color: #fff;
}
#menu ul ul li a:hover {
background: #000;
color:#fff;
}
#menu ul li.right {
float:right;
}
I have corrected your css and updated here.
html
<div id="menu">
<ul>
<li>item1 </li>
<li>item1
<ul>
<li>item1 </li>
<li>item1 </li>
<li>item1 </li>
</ul>
</li>
<li>item1 </li>
<li>item1
<ul>
<li>item1 </li>
<li>item1 </li>
<li>item1 </li>
</ul>
</li>
<li class="last">
Welcome Admin
<ul>
<li>Subitem One</li>
<li>Subitem Two</li>
<li>Subitem Three </li>
</ul>
</li>
</ul>
</div>
css
#menu {
background:#000;
width:100%;
height:40px;
border-radius: 3px;
float:left;
}
#menu ul ul {
display: none;
}
#menu ul li:hover > ul {
display: block;
}
#menu ul {
padding: 0px;
border-radius: 5px;
list-style: none;
margin:0;
position: relative;
display: block;
}
#menu ul:after {
content:"";
clear: both;
display: block;
}
#menu ul li {
float: left;
}
#menu ul li:hover {
color:#fff;
}
#menu ul li:hover a {
background:#fff;
color: #000;
}
#menu ul li a {
display: block;
padding:0 10px;
color: #FFF;
text-decoration: none;
line-height:40px;
}
#menu ul ul {
background: #fff;
padding:0;
position: absolute;
top: 40px;
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
}
#menu ul ul li {
float: none;
position: relative;
}
#menu ul ul li a {
padding: 15px 40px;
color: #fff;
}
#menu ul ul li a:hover {
background: #000;
color:#fff;
}
#menu ul li.last {
float:right;
}

html / css dropdown menu not dropping

edit
JSfiddle
Simple question, i've got the following code but i dont know what to add to my css to lift the display:none; If you need further explaining feel free to ask in the comments.
<nav>
<ul>
<li>
<a href="[[~[[+id]]]]" title="[[+pagetitle]]">
[[+longtitle:default=`[[+pagetitle]]`]]
</a>
<ul>
<li>
<a href="#" title=lorem>
[[Wayfinder? &startId=`[[+id]]` &level=`2` ]]
</a>
</li>
</ul>
</li>
</ul>
</nav>
/** Navigation **/
#nav ul{list-style: none; padding: 0; display: block;}
#nav ul li{display: inline-block; position: relative;}
#nav ul li a{ display: block; padding: 5px 8px; text-decoration: none; font-size: 16px; }
#nav ul li ul{
position: absolute;
left: 0px;
background: rgba(0,0,0,0.8);
border-radius: 0 0 5px 5px;
display: none;
z-index: 9000;
display:none;
}
.ie7 #nav ul li ul,
.ie8 #nav ul li ul{
background: url('../../assets/img/transparent-black.png') repeat;
}
#nav ul li.last ul{ right: 0px; left: auto; }
#nav ul li.last ul li a{ text-align: right; }
#nav ul li:hover ul,
#nav ul li ul:hover{ display: block; }
#nav ul li ul li{
display: block;
padding: 0;
overflow: hidden;
}
#nav ul li ul li a{
min-width: 100px;
margin: 0;
padding: 7px 14px;
color: #ffffff;
}
#nav ul li ul li:hover{ background: #f1f1f1; }
#nav ul li ul li a:hover{ color: rgba(253,183,46,1); }
nav li:hover > nav li ul li{
background-color:red;
overflow:visible;
}
nav li ul li{
display:none;
}
try this:
nav ul li ul li{
display:none;
}
nav ul li:hover > ul li{
display:block;
}
http://jsfiddle.net/vpZ5J/4/
You were trying to hide the li items in the sub-menu. Instead hide the submenu ul and then display it on hover. For that change this
nav li ul li{
display:none;
}
to
nav li ul{
display:none;
}
and add this
nav li:hover > ul{
display:block;
}
DEMO
Try adding this:
nav ul li:hover li,
nav ul li:hover ul{
display:block;
}
jsfiddle
Add the following rule:
nav li:hover, nav li:hover ul li{
display:block;
}
http://jsfiddle.net/vpZ5J/
I think what you are looking for is:
nav ul li:hover > ul {
display: block;
}
Also, you don't have div with id #nav, so all your styling is incorect, you should be using just nav

CSS dropdown menu jumping

I'm stuck with a drop down menu. The problem is that the "parent" link is jumping.
HTML:
<ul id="nav">
<li><span>Page 1</span>
<ul>
<li><a>Extralong Page 1.1</a></li>
<li><a>Page 1.2</a></li>
<li><a>Page 1.3</a></li>
</ul>
</li>
<li>Page 2</li>
<li><span>Page 3</span>
<ul>
<li><a>Page 3.1</a></li>
<li><a>Long description for page 3.2</a></li>
<li><a>Page 3.3</a></li>
<li><a>Page 3.4</a></li>
</ul>
</li>
</ul>
CSS:
* {
margin: 0;
padding: 0;
}
#nav {
float: right;
}
#nav ul {
float: left;
}
#nav li {
float: left;
padding-top: 2px;
list-style: none;
background: #3451ff;
}
#nav li a,
#nav li span {
display: block;
text-decoration: none;
font-size: 12pt;
font-weight: bold;
padding: 13px 10px 9px 10px;
}
#nav li a:link, #nav li a:active, #nav li a:visited,
#nav li span {
color: #FFF;
}
#nav li a:hover, #nav li a.active,
#nav li span:hover {
color: #000;
}
#nav li li {
display: none;
}
#nav li:hover li {
display: block;
float: none;
background: #555;
}
#nav li li a {
font-size: 10pt;
margin: 1px;
width: 100%;
background: #3c6f3a;
padding: 5px 0;
}
Demo
How can I make this parent static such that it's width isn't changed on hover? I don't want to use js.
Set a width for the parent:
#nav li {
float: left;
padding-top: 2px;
list-style: none;
width: 100px; /* Add this bad boy */
background: #3451ff;
}
DEMO HERE
You can use position:absolute and make its parent li position:relative Demo
#nav ul {
position:absolute;
right:0;
}
Use position:relative for ul parent and give position:absolute for parent child..it will be working fine.
Here is the updated fiddle :http://jsfiddle.net/nikhilvkd/gmU55/5/
#nav li li {
display: none;
position:relative;
}
#nav li:hover li {
display: block;
float: none;
position:absolute;
background: #555;
}