http://www.sage-wellness.com/nav.html
I am having a problem with this in IE7- all of the top-level navigation is stacked vertically instead of horizontally.
Here is the CSS
#navigation { width:800px; height:27px; background-image:url(images/navbg.gif); background- repeat:no-repeat; margin-top:30px; }
#navigation ul { margin:0px; padding:0px; font-family: Arial, Helvetica, sans-serif; font-size: 12px;line-height: 27px; display:inline; }
#navigation ul li { display:inline; float:left; list-style:none; height:27px; line-height:27px; position:relative; }
#navigation li a { color:#a1c301; text-decoration:none; padding-right:10px; padding-left:10px; }
#navigation li a:hover, #navigation li:hover a { color:#fff; background-color: #91b000; display:inline-block; }
#navigation li ul { margin:0px; padding:0px; display:none; position:absolute; left:0px; top:27px; background-color:#5b5b52;}
#navigation li:hover ul { display:block; width:150px;}
#navigation li li a { color:#a1c301; text-decoration:none; }
#navigation li li a:hover, #navigation li li:hover a { color:#fff; background-color: #91b000; width:130px; display:inline-block;}
#navigation li.top { }
#navigation li.top a:hover { }
#navigation ul.submenu { background-color:#5b5b52; }
#navigation li.submenu { width:150px; border: 1px dotted #999; background-color:#5b5b52; }
#navigation .submenu li a { background:#5b5b52; }
and here is the HTML
<div id="navigation">
<ul class="top">
<li class="top"> </li>
<li class="top">Home</li>
<li class="top">Acupuncture</li>
<li class="top">Chinese Medicine
<ul class="submenu">
<li class="submenu">Herbal Medicine</li>
<li class="submenu">Other Modalities</li>
</ul>
</li>
<li class="top">Conditions Treated</li>
<li class="top">About
<ul class="submenu">
<li class="submenu">Deb Valentin Bio</li>
<li class="submenu">FAQs</li>
<li class="submenu">Community Resources</li>
</ul>
</li>
<li class="top">Testimonials</li>
<li class="top">Blog</li>
<li class="top">Schedule an Appointment</li>
</ul>
</div>
ie7 doesn't understand :hover on elements other than anchors, as well as has no clue what display:inline-block means. check out suckerfish dropdowns for a solution http://www.htmldog.com/articles/suckerfish/dropdowns/
Related
Would like the last submenu of this css drop-down menu to be right-aligned: https://jsfiddle.net/mishka00/p6cyy5p7/. It is currently right-aligned (incorrectly) just to show the desired end result. Tried various combinations of right:0 and left:auto, but couldn't figure it out.
See https://jsfiddle.net/sjmcpherso/b1pyqLpc/
#nav ul li:last-child ul {
right:0px;left:auto;
text-align:right;
background:white;
}
Plus add position:relative to the parent
add position: relative for #nav ul li
add right: 0; for #nav ul li:last-child ul
#nav ul {
padding:0;
margin:0;
list-style:none;
}
#nav ul li {
float:left;
border:1px solid #fff;
margin:0 30px;
position: relative;
}
#nav ul li a {
display:block;
padding:10px 6px;
position:relative;
}
#nav ul li:hover {
border-left:1px solid #E9E9E9;
border-right:1px solid #E9E9E9;
border-top:1px solid #E9E9E9;
}
#nav ul li ul {
display:none;
}
#nav ul li:hover ul {
display:block;
position:absolute;
z-index: 10;
background:#fff;
width:150px;
border:0;
}
#nav ul li ul li {
display:block;
position:relative;
border:none;
float:none;
margin:0;
left:-1px;
}
#nav ul li ul li:hover {
border:none;
background:#F7F9FB;
}
#nav ul li ul li a {
padding:10px;
border:1px solid #E9E9E9;
}
#nav ul li:last-child ul {
right: 0;
background:white;
}
#nav ul li:last-child ul li{
left:1px;
}
<div id="nav">
<ul>
<li>Menu1
<ul>
<li>Item1
</li>
<li>Item2
</li>
<li>Item3
</li>
<li>Item4
</li>
</ul>
</li>
<li>Menu2
<ul>
<li>Item1
</li>
<li>Item2
</li>
<li>Item3
</li>
<li>Item4
</li>
</ul>
</li>
<li>Menu3
<ul>
<li>Item1
</li>
<li>Item2
</li>
<li>Item3
</li>
<li>Item4
</li>
</ul>
</li>
</ul>
</div>
<div style='clear: both;margin-bottom:5px;'></div>
<div style='border-top:1px solid navy;'></div>
just add this code to your css
#nav ul li:last-of-type {
float: right;
}
Please could someone help me. I am trying to figure out why the third level menu isn't hiding.
Thanks for your help. The url is below:
http://www.aimsmediatesting.co.uk/solar/SF/SF/
<nav class="relative sixteen columns">
<ul>
<li> Home </li>
<li> About us </li>
<li> Solar PV
<ul>
<li>Benefits of Solar Panels</li>
<li> How Solar Panels Work
<ul>
<li> Feed in Tariffs </li>
<li> How Panels are installed </li>
</ul>
</li>
<li>Why Choose Us</a></li>
<li>Insurance Backed Guarantee</a></li>
</ul>
</li>
<li> ThermoDynamic </li>
</li>
<li> Solar Thermal </li>
</li>
<li> Energy Saver Optimiser </li>
</li>
<li> Testimonials
<ul>
<li> Michael Muller </li>
<li> Gordon Porter </li>
<li> Thomas Hagan </li>
<li> John MacBean </li>
<li> Cameron CS </li>
<li> Installation Map </li>
</ul>
</li>
</ul>
</nav>
MY CSS
nav{
width:100%;
background: #118542;
display:block;
height:45px;
}
nav ul{
display:inline;
}
nav li{
float:left;
padding: 12px;
}
nav li a{
color:#fff!important;
padding:5px;
font-size:14px;
font-weight:bold;
}
nav li a{
color:#fff!important;
}
nav ul ul{
display:none;
}
nav li:hover > ul a {
background: #58595b;
padding-top: 10px;
color: #FFFFFF;
text-decoration: none;
}
nav li:hover > ul {
background: #58595b;
padding-top: 10px;
color: #FFFFFF;
text-decoration: none;
}
nav li > ul > li:hover > ul {
left: 180px;
position: absolute !important;
top: 0;
}
nav li li{
position:relative;
}
nav li li ul{
display:none;
}
nav li li ul:hover{
display:block;
position:absolute;
top:0;
left:100%;
}
nav li a:hover {
padding-top:10px;
color:#fff!important;
padding-bottom:10px;
}
nav li ul {
display:none;
height:auto;
margin:0px;
border:0px;
position:absolute;
width:200px;
z-index:200;
}
nav li:hover ul {
display:block;
}
nav li ul {
top: 34px;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:200px;
z-index:200;
}
nav li:hover ul {
display:block;
}
nav li li {
display:block;
float:none;
margin:0px;
padding:0px;
width:200px;
background:#58595b;/*this is where the rounded corners for the dropdown disappears*/
}
nav li:hover li a {
background:none;
}
nav ul li:hover a {
background:#58595b;
padding-top:10px;
color:#FFFFFF;
text-decoration:none;
}
nav li ul a {
display: block;
font-size: 12px;
font-style: normal;
margin: 0px;
padding: 10px 10px 10px 15px;
text-align: left;
}
If anyone could help me figure out what class I need to add or change I would be really grateful for your help.
Thanks
This happens due to the nav li:hover ul{display:block;} rule. it will enable all levels of submenus once a top level item is hovered..
Change it to affect only immediate children (and not descendants)
nav li:hover > ul{
display:block;
}
(also you have that rule twice in your code, so remove one of the two instances)
I want you to know before I get started that I have been looking at all of the sub sub menu questions and I didn't see anything that could help the code I already have laid out. I appreciate any help at all that anybody can give me.
So, I am trying to add a sub sub menu and I thought I had figured it out, but I don't think I quite understand how to get the child combinators to work. If you could take a look at that part of the code specifically, you would be on my 'saint list.'
ETA: Oh yeah, and the problem is that the sub sub menu does not go out to the right and show up next to the parent that it is supposed to be subbing from, which is what I want it to do. I hope that makes sense.
Here is the fiddle preview - http://jsfiddle.net/BVtSC/18/
And here is the CSS:
/*------------------------- Header ---------------------------*/
#header {
background: #333 url(../images/bg-header2.png) repeat-x;
height:184px;
margin:15px 0 0;
}
#header div {
margin:0 auto;
padding:28px 0 0;
position:relative;
width:500px;
}
#header div ul {
height:118px;
left:10px;
list-style:none;
margin:0;
overflow:visible;
padding:0;
position:absolute;
top:10px;
float: left;
width: 500px;
}
#header div ul li:first-child {
margin:0;
}
#header div ul li {
float:left;
height:66px;
margin:0 0 0 65px;
text-align:left;
position:relative;
}
#header div ul li a {
color:#fff;
font-family:oswaldregular;
font-size:16px;
line-height:24px;
text-decoration:none;
text-transform:uppercase;
}
#header div ul li.selected a, #header div ul li a:hover {
color:#DD2D00;
}
#header div ul li ul {
height:1000px;
left:-99999px;
overflow:visible;
position:absolute;
top:37px;
width:115px;
float: left;
}
#header div ul li:hover ul {
left:0;
top:37px;
}
#header div ul li ul li {
background:none #343434;
border:1px solid #4f4f4f;
float:none;
height:29px;
margin:-1px 0 0;
padding:0 12px;
position:relative;
width:auto;
z-index:1000;
}
#header div ul li ul li:hover {
background:none #DD2D00;
}
#header div ul li ul li:hover {
left:0;
top:0;
}
#header div ul li ul li a {
color:#ffffff!important;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
line-height:28px;
text-transform:none;
}
#header div ul li ul li.selected a, #header div ul li ul li a:hover {
color:#fff!important;
}
#header div ul li ul li ul {
height:1000px;
right:-99999px;
overflow:visible;
position:absolute;
top:37px;
width:115px;
float: right;
}
#header div ul li ul li:hover ul {
left:0;
top:37px;
}
#header div ul li ul li ul li {
background:none #343434;
border:1px solid #4f4f4f;
float:none;
height:29px;
margin:-1px 0 0;
padding:0 12px;
position:relative;
width:auto;
z-index:1000;
}
#header div ul li ul li ul li:hover {
background:none #DD2D00;
}
#header div ul li ul li ul li:hover {
left:0;
top:0;
}
#header div ul li ul li ul li a {
color:#ffffff!important;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
line-height:28px;
text-transform:none;
}
#header div ul li ul li ul li.selected a, #header div ul li ul li ul li a:hover {
color:#fff!important;
}
Here is the HTML:
<div id="header">
<div>
<ul>
<li> Home
</li>
<li> About
</li>
<li class="selected"> Portfolio
<ul>
<li> Fantasy
</li>
<li> Makeup
<ul>
<li>Glamour Makeup
</li>
<li>Special Effects Makeup
</li>
</ul>
</li>
<li> Boudoir
</li>
<li> Baby & Kids
<ul>
<li><a href="baby.html">Baby</li>
<li><a href="baby.html">Kids</li> </ul>
</li>
<li>
Family
<ul>
<li><a href="couples.html">Couples</li>
<li><a href="mombaby.html">Mother/Baby</li>
<li><a href="momchild.html">Mother/Child</li>
<li><a href="fatherchild.html">Father/Child</li>
</ul>
</li>
<li>
Pets
</li>
<li> Portrait
</li>
</ul>
</li>
<li> Contact
</li>
</ul>
</div>
</div>
Again, any help at all would do wonders. Thank you for your consideration. :)
three things can help you.first using '>' in css selectors. second using this
ul ul{
display:none;
}
ul > li:hover > ul {
display:block;
}
that cause a ul block being displayed when you hover on its '< li >' parent.
and third one is using css positions to adjust submenus position.like this
#header > ul{
position:relative;
}
li{
position:relative;
}
ul ul{
position:absolute;
left:120px;
top:0;
}
or you can use this which is a simple example of nested menu.(unlimited). jsfiddle
you should just adjust its size and color.
HTML
<ul class="menu">
<li>item1</li>
<li>item2
<ul>
<li>sub item1</li>
<li>sub item2</li>
<li>sub item3
<ul>
<li>sub sub item 1</li>
<li>sub sub item 2
<ul>
<li>sub sub sub item1</li>
<li>sub sub sub item2</li>
<li>sub sub sub item3
<ul>
<li>yes why not?</li>
<li>you can still continue</li>
<li>if you want</li>
<li>you can try.(-;</li>
</ul>
</li>
<li>sub sub sub item4</li>
</ul>
</li>
<li>sub sub item 3</li>
</ul>
</li>
<li>sub item4</li>
</ul>
</li>
<li>item3</li>
</ul>
CSS
ul.menu{
position:relative;
}
ul.menu li{
padding:0;
margin:0;
position:relative;
border:1px solid;
}
ul.menu > li{
float:left;
padding:10px 45px;
}
ul.menu > li li{
padding:7px;
}
ul.menu , ul.menu ul{
list-style:none;
padding:5px;
margin:0;
overflow:visible;
}
ul.menu li:hover > ul{
display:block;
}
ul.menu ul{
display:none;
position:absolute;
left:-6px;
top:37px;
width:160px;
}
ul.menu ul:hover{
display:block;
}
ul.menu ul ul{
left:158px;
top:0;
}
uMy child pages are showing up in a horizontal line under the parent page link in the navigation. I can't figure out where the css is wrong. You can see what I'm talking about here (the links under Sample Page are the ones in question): http://sitetest3.talktothedogs.com.
HTML for Navigation (which is auto-generated by WP)
<div id="nav">
<div class="menu">
<ul>
<li class="current_page_item">Home</li>
<li class="page_item page-item-2">Sample Page
<ul class='children'>
<li class="page_item page-item-4">Testing page 2</li>
<li class="page_item page-item-6">Testing page 1</li>
</ul>
</li>
</ul>
</div>
</div>
My CSS Code
.menu, .menu ul { margin:0; padding:0; list-style:none; height:29px; text-align:center; }
.menu a { color:#fff; display:block; padding-left:15px; padding-right:15px; padding-bottom:0px; }
.menu a:hover { color:#000; display:block; text-decoration:none; }
.menu li { float:left; margin:0; padding: 0px; }
.menu li li { float:left; margin: 0 0 0 5px; padding:0; width:130px; }
.menu li ul.submenu li { display:block; position:absolute; left:0; }
.menu li li a, .menu li li a:link, .menu li li a:visited { background:#a82652; width:150px; float:none; margin:0; padding: 4px 10px 5px 10px; color:#fff; }
.menu li li a:hover, .menu-header li li a:active { background:#000; width:150px; float: none; margin: 0; padding: 4px 10px 5px 10px; color:#fff; }
.menu li ul { position:absolute; width:10em; left:-999em; padding-top:13px; z-index:1; }
.menu li:hover ul { left:auto; display:block; }
.menu li:hover ul, #menu li.sfhover ul { left: auto; }
.menu li.current_page_item a { }
.menu li.current_page_item a:hover{ }
Any help would be appreciated. Thanks in advance!
Change your CSS as follows:
.menu li a{ margin-bottom:13px;}
.menu li li { float:none; margin: 0; padding:0; width:130px; }
Here is how this would look
Your first line in the CSS:
.menu, .menu ul { ... }
is setting the height of both the <div class="menu"> AND the <ul> within that .menu to the same height. The entire menu is constrained to a container that's 29px high.
I am trying to create a css horizontal drop down menu that will show the children in a horizontal subnav. What I have so far is: (this is incomplete but I am stuck)
<ul class="menu">
<li class="top">Home</li>
<li class="top">
About
<ul class="sub">
<?php wp_list_pages('title_li=&child_of=2') ?>
</ul>
</li>
<li class="top">
Services
<ul class="sub">
<?php wp_list_pages('title_li=&child_of=5') ?>
</ul>
</li>
<li class="top">
Projects
<ul class="sub">
<?php wp_list_pages('title_li=&child_of=7') ?>
</ul>
</li>
<li class="top">
Team
<ul class="sub">
<?php wp_list_pages('title_li=&child_of=10') ?>
</ul>
</li>
</ul>
and the css:
.menu {padding:50px 0 0; list-style:none; line-height:1; width:400px;}
.menu li.top {display:block; float:left; position:relative; padding:0 17px 0 0;}
.menu li a.top_link {display:block; float:left; height:40px; line-height:33px; color:#bbb;
text-decoration:none; font-size:11px; font-weight:bold; padding:0 0 0 12px;
cursor:pointer;}
.menu li a.top_link span {float:left; font-weight:bold; display:block; padding:0 24px 0
12px; height:40px;}
.menu li a.top_link span.down {float:left; display:block; padding:0 24px 0 12px;
height:40px; background:url(images/down.gif) no-repeat right top;}
.menu li a.top_link:hover {color:#000; background: url(images/button4.gif) no-repeat;}
.menu li a.top_link:hover span {background:url(images/button4.gif) no-repeat right top;}
.menu li a.top_link:hover span.down {background:url(images/button4a.gif) no-repeat right
top;}
.menu li:hover > a.top_link {color:#000; background: url(images/button4.gif) no-repeat;}
.menu li:hover > a.top_link span {background:url(images/button4.gif) no-repeat right top;}
.menu li:hover > a.top_link span.down {background:url(images/button4a.gif) no-repeat right
top;}
.menu table {border-collapse:collapse; width:0; height:0; position:absolute; top:0;
left:0;}
.menu a:hover {visibility:visible;}
.menu li:hover {position:relative; z-index:200;}
.menu ul,
.menu :hover ul ul,
.menu :hover ul :hover ul ul,
.menu :hover ul :hover ul :hover ul ul,
.menu :hover ul :hover ul :hover ul :hover ul ul {position:absolute; left:-9999px; top:-
9999px; width:0; height:0; margin:0; padding:0; list-style:none;}
.menu :hover ul.sub {left:2px; top:20px; right:2px; background: #fff; padding:3px 0;
white-space:nowrap; width:200px; height:auto;}
.menu :hover ul.sub li {display:block; height:20px; position:relative; float:left;
width:250px;}
.menu :hover ul.sub li a {float:right;font-weight:normal;display:block; font-size:11px;
color:#000; text-decoration:none;}
.menu :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul :hover ul :hover ul
{left:90px; top:-4px; background: #fff; padding:3px 0; border:1px solid 999999; white-
space:nowrap; width:93px; z-index:200; height:auto;}
I really need some help I can not get this to work at all and need to running ASAP!
Rendered HTML:
<ul class="menu">
<li class="top">Home</li>
<li class="top">
About
<ul class="sub">
<li class="page_item page-item-33">Why CVA?</li>
</ul>
</li>
<li class="top">
Services
<ul class="sub">
</ul>
</li>
<li class="top">
Projects
<ul class="sub">
</ul>
</li>
<li class="top">
Team
<ul class="sub">
<li class="page_item page-item-19">Contact Us</li>
</ul>
</li>
</ul>
Instead of fixing this mess, here's a simple example you can use and apply:
HTML
<div class='menu'>
<a href=''>One</a><a href=''>Two</a><a href=''>Three</a>
</div>
<div class='menu'>
<a href=''>One</a><a href=''>Two</a>
</div>
<div class='menu'>
<a href=''>One</a><a href=''>Two</a><a href=''>Three</a><a href=''>Four</a>
</div>
CSS
.menu { float:left; line-height:20px; border:1px solid black; height:20px;
overflow:hidden; margin-right:10px; }
.menu a { display:block }
.menu:hover { height:auto; }
Doesn't look good, but it works. You can style it to look beautiful later. (Don't forget the doctype to enable :hover.)
// Edit
Sorry just noticed the 'horizontal' part. This is a vertical dropper. Will leave it up though just in case it helps you.