New to CSS. I've got a Horizontal menu that I want to convert to a drop down menu.
Here's the CSS:
.menu_container {
position:relative;
}
ul.semiopaquemenu{ /* main menu UL */
font-family: 'Metrophobic', Arial, serif; font-weight: 800;
font-size:18px;
width: 100%;
background: #ccc;
padding: 11px 0 8px 0; /* padding of the 4 sides of the menu */
margin: 0;
text-align: left; /* set value to "left", "center", or "right" to align menu accordingly */
}
ul.semiopaquemenu li{
display: inline;
}
ul.semiopaquemenu li a{
color:white;
padding: 6px 8px 6px 8px; /* padding of the 4 sides of each menu link */
margin-right: 15px; /* spacing between each menu link */
text-decoration: none;
}
ul.semiopaquemenu li a:hover, ul.semiopaquemenu li a.selected{
color: #0080FF;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjgyIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMC4xNiIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); /* IE9+ SVG equivalent of linear gradients */
background: -moz-linear-gradient(top, rgba(255,255,255,0.82) 0%, rgba(255,255,255,0.16) 100%); /* fade from white (0.82 opacty) to 0.16 opacity */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.82)), color-stop(100%,rgba(255,255,255,0.16)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d1ffffff', endColorstr='#29ffffff',GradientType=0 );
-moz-box-shadow: 0 0 10px #595959; /* CSS3 box shadows */
-webkit-box-shadow: 0 0 10px #595959;
box-shadow: 0 0 10px #595959;
padding-top: 12px; /* large padding to get menu item to protrude upwards */
padding-bottom: 9px; /* large padding to get menu item to protrude downwards */
}
.semiopaquemenu ul {
position:absolute;
left:-9999px;
top:-9999px;
list-style-type:none;
}
.semiopaquemenu li:hover {
position:relative;
}
.semiopaquemenu li:hover ul {
left:0px;
top:30px;
padding:3px;
width:160px;
}
.semiopaquemenu li:hover ul li {
height:18px;
border:none;
}
.semiopaquemenu li:hover ul li a {
height:18px;
padding:0px;
display:block;
width:158px;
line-height:18px;
text-indent:5px;
}
.semiopaquemenu li:hover ul li a:hover {
height:18px;
}
Here's my HTML:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options</li>
</ul>
How can I convert menu item "Options" to a drop down???
Thanks!
demo jsBin
Add this lines and play around:
CSS:
ul.semiopaquemenu > li > ul{
background:#ccc;
padding:15px 20px;
}
ul.semiopaquemenu > li > ul li {
color:white;
cursor:pointer;
display:block;
padding:4px 10px;
}
HTML:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>
Options
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
<li>Option 4</li>
</ul>
</li>
</ul>
Well, for starters you'll need some extra list items to actually have something to "drop down", so another <ul>. The place to put it is <li>Options RIGHT HERE </li>. To get something going, just copy/paste the HTML you already have into itself at that point:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options</li>
</ul>
</li>
</ul>
Which with your current CSS produces this, a working drop down menu: http://jsfiddle.net/yAmWb/
Related
I am trying to understand a tutorial on making a CSS dropdown menu.
(source: line25.com)
In the image above, the left border of the submenu is aligned to the left border of the parent. I want the right border of the submenu to align to the right border of the parent, whilst retaining the submenu's width. i.e. the submenu should be translated to the left a little.
I tried to add position: relative; to the direct parent of the submenu, but the text "Web Design" breaks into 2 lines; that's ugly.
The tutorial is from dropdown menu.
Here is my code:
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
/*position: relative;*/
}
nav ul li:hover {
background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -webkit-linear-gradient(top, #4f5964 0%, #5f6975 40%);
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 25px 40px;
color: #757575;
text-decoration: none;
}
nav ul ul {
background: #5f6975;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #4b545f;
}
<nav>
<ul>
<li>Home</li>
<li>Tutorials
<ul>
<li>Photoshop</li>
<li>Illustrator</li>
<li>Web Design
</li>
</ul>
</li>
<li>Articles
<ul>
<li>Web Design</li>
<li>User Experience</li>
</ul>
</li>
<li>Inspiration</li>
</ul>
</nav>
You would relatively position the parent li element:
nav > ul > li {
position: relative;
}
and then set the position of the direct ul child to right: 0:
nav > ul > li > ul {
right: 0;
}
In doing so, the child ul is absolutely positioned relative to the parent.
..and if you want to prevent the text from wrapping, add white-space: nowrap.
nav > ul > li > ul {
right: 0;
white-space: nowrap;
}
I have a tabular navigation list (with the styles I choose for) in an external file contains the following code:
.tabs
{
position:relative;
text-align:left; /* This is only if you want the tab items at the center */
width: 90%;
padding: 0;
margin: 0;
/*border: 1px solid green;*/
}
.tabs ul.menu
{
list-style-type:none;
display:block; /* Change this to block or inline for non-center alignment */
width:570px;
/* min-width:570px;
max-width:800px;
vertical-align: bottom;
/*border: 1px solid red;*/
}
.tabs ul.menu > li
{
display:inline;
float:center;
vertical-align: bottom;
/** border: 1px solid yellow;*/
cursor:hand;
}
.tabs ul.menu li > a
{
color:#7a7883;
text-decoration:none;
display:inline-block;
text-align:center;
border:1px solid #f1f3f4;
padding:5px 10px 5px 10px;
width: 25%;
font-size:15px;
font-family:"Times New Roman", Times, serif;
border-top-left-radius:5px; -moz-border-radius-topleft:4px; -webkit-border-top-left-radius:5px;
border-top-right-radius:5px; -moz-border-radius-topright:4px; -webkit-border-top-right-radius:5px;
-moz-user-select:none;
cursor:hand;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#aeb8c0));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #aeb8c0, #fff);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #aeb8c0, #fff);
/* IE 10 */
background: -ms-linear-gradient(top, #aeb8c0, #fff);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #aeb8c0, #fff);
}
.tabs ul.menu li > a:hover
{
color: #fff;
cursor:hand;
}
.tabs ul.menu li > div
{
display:none;
position:absolute;
width:98%;
/* max-width:700px;*/
min-height:230px;
left:0;
margin: 0 15px 0 15px;
z-index:-1;
text-align:left;
padding:0;
}
.tabs ul.menu li > div > p
{
border:1px solid #f1f3f4;
background-color: #f5f9fc;
width: 99%;
padding:10px;
margin:0;
color: #65636e;
font-size:12px;
font-family:"Times New Roman", Times, serif;
text-decoration: none;
min-height:200px;
}
.tabs ul.menu li > a:focus
{
color: #f5f9fc;
}
.tabs ul.menu li:target > a
{
cursor:default;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1f3f4), to(#fff));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #fff, #f1f3f4);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #fff, #f1f3f4);
/* IE 10 */
background: -ms-linear-gradient(top, #fff, #f1f3f4);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #fff, #f1f3f4);
cursor:hand;
}
.tabs ul.menu li:target > div
{
display:block;
}
and in the web page I have this:
<!-- Side NAVIGATION -->
<!-- Wrapper 2-Content -->
<div class="wrapper" style="min-height: 200px;"">
<!-- content -->
<div class="content">
<div class="tabs">
<ul class="menu">
<li id="item-1">
Bla Bla 1
<div><p>Tab Content 1</p></div>
</li>
<li id="item-2">
Bla Bla 2
<div><p>Tab Content 2</p></div>
</li>
<li id="item-3">
Bla Bla 3
<div><p>Tab Content 3</p></div>
</li>
</ul>
</div>
</div>
<!-- content -->
<!-- end of Side NAVIGATION -->
All goes fine except that it displays the tabs only without the box where the content should appear. I want one of the contents to be visible as default. I just don't know how to activated it without using javaScript.
Thank you in advanced.
add display : block as style for the div which u want to display by default. For example see this fiddle I hv created for making item1 visible on run http://jsfiddle.net/X6Agf/
<div style="display:block"><p>Tab Content 1</p></div>
I for whatever reason cannot get rid of the gap between my header and the nav bar menu. I've tried every adjustment of padding/margins I can think of to either push it up or move the bar, but it just does funky stuff with the menu or pushes other content up. I need some help.
and the code
#header_wrap {
width:100%;
height:144px;
text-align: center;
}
#header {
width:980px;
margin:0 auto;
}
#preloadedImages
{
width: 0px;
height: 0px;
display: none;
background-image:url(Logo/logo14hover.gif);
}
.site_logo {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14.gif) no-repeat;
}
.site_logo:hover {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14hover.gif) no-repeat;
}
.headerpic {
float:left;
width:678px;
height:144px;
background:url(Images/headerpic.gif) no-repeat;
}
#menu_wrap {
position:relative;
z-index:2;
text-align:center;
width:100%;
padding: 0px 0px;
}
#menu {
position:relative;
z-index:2;
width:1000px;
text-align:center;
margin:0 auto;
height:61px;
padding: 0px 0px;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
box-shadow: 0px 0px 9px rgba(0,0,0,0.5);
padding: 0px 0px;
list-style:none;
position: relative;
display:inline-table;
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
text-shadow: 1px 1px #000000;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #736e57;
background: linear-gradient(top, #BBB38F 0%, #6B6441 40%);
background: -moz-linear-gradient(top, #BBB38F4 0%, #6B64415 40%);
background: -webkit-linear-gradient(top, #BBB38F 0%,#6B6441 40%);
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover a {
color:#FFFFFF;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li a {
color:#FFFFFF;
display: block;
padding: 12px 42px;
text-decoration:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover > ul {
background: #303030;
text-decoration:none;
display: block;
}
nav ul ul {
background: #303030;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:14px;
text-decoration:none;
color:#000;
font-weight:light;
outline:none;
filter:alpha(opacity=95);
opacity: 0.95;
-moz-opacity:0.95;
}
nav ul ul li {
text-decoration:none;
float: none;
position: relative;
}
nav ul ul li a {
text-decoration:none;
padding: 0px 0px;
color:#000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul li a:hover {
text-decoration:none;
background: #736e57;
text-shadow: 1px 1px #000000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul {
text-decoration:none;
padding: 0px;
position: absolute;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
padding: 10px 40px 10px 15px;
color:#000;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
text-align: left;
}
nav ul ul li a:hover {
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
background: #6B6441;
text-align: left;
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul ul {
position: absolute;
left: 100%; top:0;
}
and the HTML
<div align="center" id="header_wrap">
<div id="header">
<div id="preloadedImages"></div><div class="site_logo"></div>
<div class="headerpic"></div>
</div>
</div>
<!-- START MENU NAV BAR CODE -->
<div id="menu_wrap">
<div id="menu">
<nav>
<ul>
<li>Company
<ul>
<li>Mission</li>
<li>Philosophy</li>
</ul>
</li>
<li>Solutions
<ul>
<li>Q Pipe Estimator
<ul>
<li>Advantage</li>
<li>Differentiator</li>
<li>Features</li>
<li>Screen Shots</li>
</ul>
</ul>
</li>
</li>
<li>Services
<ul>
<li>Technical Support</li>
<li>Training</li>
<li>Customization</li>
<li>FAQ's</li>
</ul>
</li>
<li>Industry
<ul>
<li>Focus</li>
<li>Customers</li>
</ul>
</li>
<li>Contact
<ul>
<li>Contact Information</li>
<li>Request Information</li>
</ul>
</li>
<li>Login
</li>
</ul>
</nav>
</div>
</div>
<!-- END MENU NAV BAR CODE -->
added fiddle link in comments
Simply remove the default margin for your main ul (the direct descendant of nav)
Select it using the following CSS, or giving that specific ul a class or id (this way you target only the ul causing you trouble).
nav > ul {margin: 0}
I stuck it into the top of your fiddle, and updated it here
I realise this has now been answered because I took way too long formatting this, but I'd just like to point out that it has nothing to do with the box-shadow which has no impact on positioning.
The ul default margin is responsible for this space. Try setting margin-top:0 to nav ul. Demo: http://jsfiddle.net/xtsAx/8/
for me the error was because i used dream weaver to edit my code.
this give me a hiccup by adding default headers.
when i removed those headers and just gave<html> <head>...<?php>....?> .... </html> it worked perfect.
always remove html tags and header by dream weaver.
**Update: I had the same error again in Firefox so i applied
*{
margin:0;
padding:0;
}
And hence got rid of it completely now.
**
For some reason the z-index is not working properly in ie7 only. If I remove position:fixed from #header it works fine, however, as this menu is to be fixed at the top of the page this is needed. The drop down shows, but only over the bottom border and nothing below that. Can't figure this one out.
fiddle
<!-- start fixed header container -->
<div id="header_container">
<!-- start header -->
<div id="header">
<!-- start container -->
<nav>
<div class="container">
<div id="logo">logo here</div>
<div id="top_menu">
<ul>
<li>Features
<div class="drop">
<div>
<ul>
<li class="title">heading with link</li>
<li>testing 1</li>
<li>testing 2</li>
<li>testing 3</li>
</ul>
<ul>
<li class="title">and another heading</li>
<li>testing 1</li>
<li>testing 2</li>
<li>testing 3</li>
</ul>
</div>
<div class="extra">
<ul>
<li class="title">heading with NO link</li>
<li>testing 4</li>
<li>testing 5</li>
<li>testing 6</li>
</ul>
<ul>
<li class="title">plain info description goes as far as I want <br />with no link blah blah blah blah blah</li>
</ul>
</div>
</div>
</li>
<li>Download</li>
<li>Purchase</li>
<li>Support
<div class="drop">
<div>
<ul>
<li class="title">How can we help you?</li>
<li>FAQs</li>
<li>How To Guides</li>
<li>Online Documentation</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</li>
<li>Account Login</li>
</ul>
</div>
</div>
</nav>
<!-- end container -->
<div class="header_shadow"></div>
</div>
<!-- end header -->
</div>
<!-- end header container -->
#header_container{
width:100%;
height:52px;
}
#header{
width:100%;
height:50px;
position:fixed;
border-bottom:2px #3c9ac4 solid;
background: #00457b;
background-image: -webkit-gradient(linear, left top, left bottom, from(#1e70b2), to(#00457b));
background-image: -webkit-linear-gradient(top, #1e70b2, #00457b);
background-image: -moz-linear-gradient(top, #1e70b2, #00457b);
background-image: -ms-linear-gradient(top, #1e70b2, #00457b);
background-image: -o-linear-gradient(top, #1e70b2, #00457b);
background-image: linear-gradient(top, #1e70b2, #00457b);
}
.ie8 #header, .ie9 #header{
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e70b2', endColorstr='#00457b',GradientType=0 ) ;
}
.header_shadow{
width:100%;
height:10px;
position:absolute;
z-index:900;
display:none;
left:0;
top:52px;
background:url(/images/header_shadow.png) repeat-x;
}
/* Top Menu
================================================== */
#logo{
width:200px;
float:left;
}
/*menu container centered*/
#top_menu{
width:760px;
float:left;
}
/*entire menu ul*/
#top_menu ul{
position:relative;
z-index:1000;
margin:0;
float:right;
height:50px;
line-height:50px;
}
/*top link container*/
#top_menu ul li{
display:block;
float:left;
}
/*top link*/
#top_menu ul li a{
display:block;
color:#f1f1f1;
text-decoration:none;
padding:0 20px;
font-size:14px;
}
/*top link hover*/
#top_menu ul li:hover > a{
color: #f1f1f1;
background:#555555;
}
/*show dropdown and position under tab*/
#top_menu ul li:hover > .drop{
display:block;
top:auto;
}
/*drop down container*/
#top_menu ul li .drop{
position:absolute;
z-index:1000;
display:none;
padding:15px 0 0 0;
-moz-border-radius:0 0 8px 8px;
-webkit-border-radius:0 0 8px 8px;
border-radius:0 0 8px 8px;
background:#555555;
background-image: -webkit-gradient(linear, left top, left bottom, from(#555555), to(#202020));
background-image: -webkit-linear-gradient(top, #555555, #202020);
background-image: -moz-linear-gradient(top, #555555, #202020);
background-image: -ms-linear-gradient(top, #555555, #202020);
background-image: -o-linear-gradient(top, #555555, #202020);
background-image: linear-gradient(top, #555555, #202020);
font-size:13px;
}
.ie8 #top_menu ul li .drop{
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#555555', endColorstr='#202020',GradientType=0 ) ;
}
.ie9 #top_menu ul li .drop{
background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8bGluZWFyR3JhZGllbnQgaWQ9Imc1ODIiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMTAwJSI+CjxzdG9wIHN0b3AtY29sb3I9IiM1NTU1NTUiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiMyMDIwMjAiIG9mZnNldD0iMSIvPgo8L2xpbmVhckdyYWRpZW50Pgo8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2c1ODIpIiAvPgo8L3N2Zz4=);
}
/*drop down div*/
#top_menu ul li .drop div{
float:left;
padding:0 30px 0 10px;
line-height:normal;
}
/*drop down div floated left*/
#top_menu ul li .drop div.extra{
/*border-left:1px #eeeeee solid;*/
}
#top_menu ul li .drop div .title, #top_menu ul li .drop div .title a{
padding:0 0 4px 0;
border:none;
color:#f1f1f1;
font-size:13px;
}
#top_menu ul li .drop div .title a:hover{
text-decoration:underline;
}
#top_menu ul li .drop div ul{
width:auto;
height:auto;
float:none;
background:none;
border:none;
margin:0 0 15px 0;
}
#top_menu ul li .drop div ul li{
float:none;
padding:1px 0 1px 0;
line-height:normal;
}
#top_menu ul li .drop div ul li:hover a{
background:none;
}
#top_menu ul li .drop div ul li a{
display:inline;
padding:0;
border:none;
color:#6cc5d8;
font-size:13px;
}
#top_menu ul li .drop div ul li a:hover{
text-decoration:underline;
}
I was able to solve the issue by adding yet another wrapper wound the header and making it position fixed. So it goes as container the width/height (to keep spacing of the rest of the page correct), container width/height fixed, then header container with logo/drop-down within that. Solves the problem in ie7 and every other browser worked fine before.
I am soooo confused! Here is the site I'm developing: Cancer Support site
I seem to have two problems... that I have spent hours and hours trying to figure out the solution.. so I really hope someone can help.
Problem 1: I use an ID=navactive to keep the parent menu item active if it is the current page being diplayed. That works. However, the way I have coded the CSS, it has introduced an error by making the submenu items appear active when they first appear upon mousever of an ID=navactive parent. Instead the submenu items should initially appear as inactive until they are actually moused over. On the site, you can see that the "Home" page is the active page on the parent menu. If you mouse over it, the two children submenus appear.. but they show up active. They should appear as inactive - the same way as the submenus do when you mouse over the "Our Work" parent menu item.
Problem 2: None of my grandchildren submenu items appear at all.. Under both the "Home" and "Our Work" parent menu items I have the following configuration:
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (grandchild 1)
Submenu 3 (child 2)
Instead it appears on the page like this where the grandchild 1 becomes the child 2, and no grandchildren are viewable (and the original child 2 [submenu 3] is missing):
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (child 2)
Any suggestions would be greatly appreciated!!!
Thanks!
For your convenience.. here is my css code for the nav menu section:
#navcontainer
{
width: 711px;
height: 25px;
text-align: center;
margin: 0px auto; /*Center container on page*/
clear: both;
background-color: #129F9F;
border: 3px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Opera */
background-image: -o-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #16ACAC), color-stop(1, #0D6F6F));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #16ACAC 0%, #0D6F6F 100%);
}
.main_menu
{
height: 24px;
line-height: 24px;
font-size: 12px;
position: relative;
}
.main_menu ul
{
padding: 0px 0px 0px 35px; /* padding on left to get nav menu to center.. since it has a float left to make it display properly*/
list-style: none;
}
.main_menu ul li
{
padding: 0;
margin: 0;
border-right: 2px solid #129F9F;
float: left;
}
.main_menu ul li.navcontact /* to stop right border at end of nav line */
{
padding: 0;
margin: 0;
border-right: none;
float: left;
}
.main_menu ul li a
{
color: #FFF;
display: block;
text-decoration: none;
padding: 0 15px;
}
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
{
text-decoration: none;
color: #EAA339;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Opera */
background-image: -o-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0D6F6F), color-stop(1, #16ACAC));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #0D6F6F 0%, #16ACAC 100%);
}
.main_menu ul li ul
{
display: none;
width: auto;
position: absolute;
padding: 0px;
margin: 0px;
}
.main_menu ul li:hover ul
{
display: block;
position: absolute;
margin: 0;
padding: 0;
}
.main_menu ul li:hover li
{
float: none;
list-style: none;
margin: 0px;
}
.main_menu ul li:hover li
{
font-size: 12px;
height: 24px;
background: #54C4C4;
/* border-top: 1px solid #129F9F; */
border: 1px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
.main_menu ul li:hover li a
{
font-size: 11px;
color: #fff;
padding: 0px;
display: block;
width: 150px;
}
.main_menu ul li li a:hover
{
font-size: 11px;
height: 24px;
color:#EAA339;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
And here is the HTML code:
<div id="navcontainer">
<div class="main_menu">
<ul>
<li id="navactive">Home
<ul>
<li>submenu 1
<ul>
<li>submenu 2</li>
</ul>
</li>
<li>submenu 3</li>
</ul>
</li>
<li>What is CSFF
<ul>
<li>submenu 4</li>
</ul>
</li>
<li>Make a Donation</li>
<li>Our Work
<ul>
<li>submenu 5
<ul>
<li>submenu 6</li>
</ul>
</li>
<li>submenu 7</li>
</ul>
</li>
<li>Events Outline</li>
<li class="navcontact">Contact Us</li>
</ul>
</div>
</div>
The reason you are getting this problem is due to your CSS and the way you have structured your HTML code. Here is your problem -
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
{
STYLES
}
Simply change the "#navactive a:link" part of your CSS code above to a seperate class that handles the active link. Currently any link within the "navactive" div will inherit the styles given in this class, and this is why the sub menu text is appearing yellow and not white. So like I said change the above CSS code to a separate class, eg - "#navactive .current"
and then change your HTML code to look like this:
<div id="navcontainer">
<div class="main_menu">
<ul>
<li id="navactive"><a class="current" href="index.asp" title="Cancer Support for
Families Foundation is a community funded, community focused cancer charity.">Home</a>
That should do the trick! Obviously I haven't been able to test it, but let me know if you have any problems. Also just a tip - using the Chrome 'Inspect Element' function is really useful when faced with these kind of problems!
Problem 1
in the css:
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
you should put a > in #navactive a:visited, and #navactive a: link so it looks like this:
.main_menu ul > li:hover > a, #navactive > a:link, #navactive > a:visited, #navactive > ul > li > a:hover
the ">" means you direct only the child element