Ive been trying to make the original dropdown into multi level for a site im working on. All of my attempts have failed (. For some reason i can only do "margin-right" to align the elements, and this causes some problems. I think it has something to do with the position attribute.
Here is my HTML:
<ol id="nav">
<li>Home</li>
<li class="dropdown_alignedLeft">
Products
<ul><li class="dropdown_alignedRight">
iPoP
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>iPoP - Network Solutions for Vessels</li></ul><li class="dropdown_alignedRight">
Cameras
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>iCam 501 Ultra - Intrinsically Safe Digital Camera with Flash</li></ul><li class="dropdown_alignedRight">
BNWAS
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>BNWAS - Bridge Navigation Watch Alarm System</li></ul><li class="dropdown_alignedRight">
Lighting
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>Peli 2690 - Intrinsically Safe LED Head Lamp</li></ul><li class="dropdown_alignedRight">
Communication
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>Ex-Handy 06 - Intrinsically Safe Cell Phone</li></ul>
</ul>
<li class="dropdown_alignedLeft">
Customers
<ul>
<li>Maritime</li>
<li>Non-Maritime</li>
<li class="dropdown_lastItem">Regulatory Organizations</li>
</ul>
<li>Product Enquiry</li>
<li>Contact Us</li>
<li class="dropdown_alignedLeft">
Company
<ul>
<!-- <li>About Us</li> -->
<li>News</li>
<li class="dropdown_lastItem">Press Releases</li>
</ul>
</ol>
And my CSS:
#nav {
float:right;
margin:15px 0 0;
}
#nav li {
float:left;
}
#nav li a {
display:block;
font-family:"PT Sans","Helvetica Neue",Arial,sans-serif;
font-size:16px;
text-decoration:none;
color:#2B95C8;
padding:10px 20px 20px;
}
.dropdown_alignedLeft,.dropdown_alignedRight {
position:relative;
}
#nav .dropdown_alignedLeft>a,#nav .dropdown_alignedRight>a {
background:url(../images/dropdown_arrow_blue.png) no-repeat top right;
padding:10px 30px 20px 20px;
}
#nav .dropdown_alignedLeft:hover>a,#nav .dropdown_alignedRight:hover>a {
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
-moz-border-radius-bottomright:0;
-moz-border-radius-bottomleft:0;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
-webkit-border-bottom-right-radius:0;
-webkit-border-bottom-left-radius:0;
border-top-left-radius:5px;
border-top-right-radius:5px;
border-bottom-right-radius:0;
border-bottom-left-radius:0;
color:#FFF;
background:#2378A1 url(../images/dropdown_arrow_blue.png) no-repeat bottom right;
}
.dropdown_alignedLeft ul,.dropdown_alignedRight ul {
display:none;
}
#nav .dropdown_alignedLeft:hover>ul,#nav .dropdown_alignedRight:hover>ul {
display:block;
z-index:100;
position:absolute;
top:50px;
-moz-border-radius-topleft:0;
-moz-border-radius-topright:0;
-moz-border-radius-bottomright:5px;
-moz-border-radius-bottomleft:5px;
-webkit-border-top-left-radius:0;
-webkit-border-top-right-radius:0;
-webkit-border-bottom-right-radius:5px;
-webkit-border-bottom-left-radius:5px;
border-top-left-radius:0;
border-top-right-radius:0;
border-bottom-right-radius:5px;
border-bottom-left-radius:5px;
background:#2378A1;
padding:0 0 6px;
}
#nav .dropdown_alignedRight:hover>ul {
top:50px;
right:0;
text-align:right;
}
#nav li ul li {
float:none;
border-bottom:1px dashed #2B95C8;
margin:0 20px;
}
#nav li ul li.dropdown_innerTitle {
border:none;
font-family:"Helvetica Neue",Arial,sans-serif;
font-size:15px;
white-space:nowrap;
color:#C8DDE7;
margin:10px 20px 0;
padding:10px 0;
}
#nav li ul li.dropdown_lastItem {
border:none;
}
#nav li ul li a {
font-family:"Helvetica Neue",Arial,sans-serif;
font-size:13px;
color:#FFF;
white-space:nowrap;
padding:10px 0 9px;
}
#nav>li:hover>a,#nav li .current_page {
color:#2378A1;
background:url(../images/current_page_arrow_blue.png) no-repeat center bottom;
}
#nav li ul li a:hover {
color: #C8DDE7;
}
For a live version of the menu, please go here:
JSFiddle - Live Menu
You weren't closing a lot of your li tags and your submenu was just sort off flying off its container. Cleaned up your code and made too many modifications to list here:
http://jsfiddle.net/MmHSd/4/
http://purecssmenu.com/ Might help you out. Try downloading a list and taking a look at it. Deleting all the extra tags you have and take everything back to a basic list like this:
<ul>
<li>Element 1</li>
<li>Element 2</li>
<ul>
<li>
Element 2 Child 1
</li>
<li>
Element 2 Child 2
</li>
</ul>
and working back up to something a bit more complicated might help too.
Related
I have a navigation menu with this style. The menu is perfect on Chrome, but other browsers and some Firefox versions, the menu shows up as 2 lines. I cannot get this line of CSS "padding: 0 0.73em;" to work on all browsers.
.mainnav ul {
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
.mainnav ul li {
float:left;
}
.mainnav ul li a:link,.mainnav ul li a:visited {
display:block;
font-size:13px;
font-weight:bold;
color:#FFFFFF;
background-color:#B79527;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
margin:0;
padding: 0 0.73em;
height: 28px;
line-height: 28px;
position:relative;
white-space:nowrap;
}
.mainnav ul li a:hover,.mainnav ul li a:active {
background-color:#9A7C1C;
}
#firstmenu {
background:#7A4AAD;
padding-left: 6px;
}
Here is the HTML
<div class="mainnav">
<ul>
<li id="firstmenu">Home</li>
<li>Group News</li>
<li>About us</li>
<li>Vision Message and Mission</li>
<li>Group Activity</li>
<li>Chairman's Message</li>
<li>Jobs</li>
<li>Contact us</li>
</ul>
</div>
Even Firefox gives me different results on different machines.
you are aware that in: .mainnav ul li a:link,.mainnav ul li a:visited there are double padding decalarations?
padding:4px;
padding: 0 0.73em;
You can combine those:
padding: 4px 0.73em;
Seems that the issue with the navigation list is that there is too much spacing in between them in combination with the amount of items.
I there are too much items, the normal behavior is the wrapping, you could decrease spacing, font-size to fix this.
So, I'm trying to create a horizontal rollover menu .
Things were fine until I start working on my "current page" to show where the visitor is on the navigation bar.
I wanted to do so with a class named "active".
I want the sub menu to be visible at all time.
It seems like the <li> (from my navigation ) which are earlier in the html code than the one with the class "active", doesn't react as they are supposed to when mouse hovered; The sub menu doesn't show anymore...
I'm not sure if I'm clear or if I'm making any sense, It is still a new technology to me and explaining what's going on is quite hard.
Please let me know if you can help me or if you want me to explain differently.
Thanks a lot
Mick
UPDATES
Here are some screenshots of were I am now thanks to Wire42 (I add some lower Z index to the sub menu item as well as a white background).
So now the previous element react properly to the mouse hover but the active element (in the example "take action") doesn't show the sub menu.
image 1: the active item doesn't show the sub menu (it should show sub menu even when not mouse hovered)
image 2: problem solved for the mouse hovered items
Am I missing something?
CSS
#menu_wrapper {
padding:0;
margin:0;
position:relative;
left:108px;
top:2px;
}
#menu {
width:812px;
height:28px;
background-color: #B4B4B4;
padding:0 0 0 60px;
}
#menu li {
display: inline;
list-style-type: none;
}
#menu li a {
font-size: 13px;
text-transform: uppercase;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;
float: left;
color: #000000;
padding: 6px 13px;
border-right: 1px solid #999;
}
/* get rid of last border in menus*/
#menu li:last-child a, #menu li.active li:last-child a, #menu li:hover li:last-child a{
border:none;
}
#menu li:hover > a {
background-color: #e9748b;
}
#menu li.active > a {
background-color: #e9748b;
}
/*-------------------SUB MENU---------------*/
#menu li ul {
display:none;
padding:0 0 0 60px;
}
#menu li:hover > ul {
display:block;
position:absolute;
padding: 0 0 0 90px;
left:0; top:28px;
background:url(Images/background_sub_menu.png) repeat-x;
width:782px;
min-height:23px;
}
#menu li.active > ul{
display:block;
position:absolute;
padding: 0 0 0 90px;
left:0; top:28px;
background:url(Images/background_sub_menu.png) repeat-x;
width:782px;
min-height:23px;
z-index: -1;
}
#menu li li {
list-style:none;
}
#menu li li a, #menu li.active li a{
color:#000000;
background:none;
text-decoration:none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
text-transform: none;
border-right: 1px solid #999;
padding:5px 10px;
margin:0;
}
#menu li.active li a{
z-index:-1;
}
#menu li li a:hover {
background:none;
font-weight: bolder;
color: #000000;
background-color: #CC6633;
}
#menu li li.active a {
text-decoration:underline;
background:none;
font-weight: bolder;
color: #000000;
z-index:-1;
}
HTML
<ul id="menu">
<li>Home
<ul>
<li> </li>
</ul>
</li>
<li>About the Foundation
<ul>
<li>What we do</li>
<li>Who we are</li>
<li>Goals for 2012</li>
<li>Annual reports</li>
<li>Help 4 Guys .com</li>
</ul>
</li>
<li>Programs
<ul>
<li>Male Abuse Awarness Week</li>
<li>Help 4 Guys .com</li>
<li>Events</li>
</ul>
</li>
<li class="active">Take Action
<ul>
<li>Volunteer for PLF</li>
<li>Help our Foundation</li>
<li class="active">Donate</li>
<li>FAQ</li>
</ul>
</li>
<li>Find Support
<ul>
<li>Child Abuse FAQ</li>
<li>Find Support Near You</li>
<li>Support for the Families</li>
<li>Privacy</li>
<li>Our Network</li>
</ul>
</li>
<li>Contact Us
<ul>
<li></li>
</ul>
</li>
</ul>
Here's a solution using purely CSS, no javascript:
http://jsfiddle.net/nammp/1/
This code does two things (which, as I answer this, are hacked in there, but I will go back and clean it up if someone else doesn't get to it first):
Active elements receive a z-index of -1 and so are rendered under the hover elements
Hover elements get a white background-color so they visually hide the active elements
I think this solves the problem. Hopefully we can clean up this question so the code is a little more generic.
I changed UL li menu with working sample.
please look into the link. http://jsfiddle.net/abhishekbhalani/ZzF6S/
Let me know if any issue.
Refer below urls, I think it would be useful for you.
Tab changes on Mouseover
simple css hover tab thingy
Thanks
Abhishek
I trying to set up my nav so I have my list items and i have a list inside a list item (sub-menu) like so...
<style>
.headerNav{
color:#FFF;
margin:0 auto;
width: 1280px;
padding-top: 148px;
}
.headerNav ul{
list-style-type:none;
margin:0;
padding:0 0 0 8px;
}
.headerNav li{
float:left;
}
.headerNav ul a{
font-size:24px;
color:#FFF;
display:block;
padding:0 55px 0 0;
text-decoration:none;
text-transform:capitalize;
}
.headerNav ul a:hover{
color:#a40404;
text-decoration:none;
}
</style>
<div class="headerNav">
<ul>
<li>Home</li>
<li><a href="#" class='galleryNavToggle'>Gallery</a>
<ul>
<li>Categoies</li>
<li>Products</li>
</ul>
</li>
<li><a href="#" class='galleryNavInfoToggle'>Info</a>
<ul>
<li>F.A.Q.</li>
<li>CV</li>
<li>Artist Bio</li>
<li>Video</li>
<li>Contact</li>
</ul>
</li>
</ul>
</div><!-- headerNav -->
The problem is that the list items with a list inside have a massive width and I cant see my sub nav at all, any help would be greatly appreciated.
I've created a fiddle with your html and css and added a bit of css of my own to outline the sublist a bit better: http://jsfiddle.net/bymLV/
I removed float: left from the sublist, because this is what makes your list so extremely wide. That and the actual width of 1280px you are giving .headerNav.
Trying to make a drop down menu with css but it has some weird bugs in it. Here is the link for the site I'm working on.
http://shekinahgloryfire.com/?page=about
My CSS is like this:
#nav ul{float:left;margin-top:95px;list-style:none;padding-left:140px;}
#nav .first{border-radius:10px 0 0 10px;-webkit-border-radius:10px 0 0 10px; -moz-border-radius:10px 0 0 10px;}
#nav .last{border-radius:0px 10px 10px 0;-webkit-border-radius:0px 10px 10px 0; -moz-border-radius:0px 10px 10px 0;}
#nav ul li{float:left;border:solid #000;border-width:1px 0 1px 1px;background:black url('../images/navbg.gif');overflow:hidden}
#nav ul li:hover{background:#f68f1e url('../images/activebg.gif')}
#nav ul li a:link{text-transform:uppercase; text-decoration:none; font-family:serif; font-size:10pt; font-weight:bold; color:#fff; width:100px; height:40px; display:block; text-align:center; padding-top:10px}
#nav ul li a:hover{color:#000;text-decoration:underline;}
#nav ul ul{ position:absolute; }
And my mark up is like this:
<div id="nav">
<ul>
<li class="first"><a class="first" style="<?php if($page == "home") print "background:#f68f1e url('images/activebg.gif');color:#000";?>" href="?page=home">Home</a></li>
<li>About
<ul>
<li>Testimonies</li>
</ul>
</li>
<li>Resources</li>
<li>Videos</li>
<li class="last">Contact</li>
</ul>
</div>
If you are saying about spacing between the logo+nav and the actual content, then you need to decrease the height value in .header class of your stylesheet.
I figured it out. I just rewrote the whole navigation from scratch. Then I decided to do away with the dropdown and just put it on the side navigation.
I have a problem with Firefox I have a drop down menu at the top of my website this is the code for the CSS
#zone-bar {
background:#E5E5E5;
min-height:30px;
z-index:10;
padding:5px 10px 0;
}
#zone-bar ul li {
float:left;
height:18px;
margin-right:10px;
position:relative;
z-index:10;
padding:5px 5px 0;
}
#zone-bar ul li:hover {
background:#C0C0C0;
}
#zone-bar ul li a {
color:#383838;
display:block;
float:left;
font-size:1.1em;
font-weight:700;
height:23px;
padding-right:3px;
position:relative;
right:-5px;
text-decoration:none;
top:-5px;
}
#zone-bar ul li a:hover,#zone-bar ul li a.zoneCur {
background:url(images/right-hover.png) center right no-repeat;
z-index:10;
}
#zone-bar ul li a span {
position:relative;
top:6px;
}
#zone-bar ul li ul {
background:#FFF;
border:1px solid #ccc;
display:none;
left:0;
position:absolute;
top:29px;
width:150px;
padding:10px 0 0;
}
#zone-bar ul li ul li {
float:none;
height:100%;
margin:0;
padding:0;
}
#zone-bar ul li ul li:hover {
background:none;
}
#zone-bar ul li ul li a {
display:block;
float:none;
margin-left:-5px;
width:140px;
padding:5px 0 0 10px;
}
#zone-bar ul li ul li a:hover {
background:#C0C0C0;
}
#zone-bar ul {
display:block;
}
This is my HTML code
<div id="zone-bar">
<ul><li>
<span>My Account <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>My Account</li>
<li>My Channel</li>
<li>My Videos</li>
<li>Favorites</li>
<li>Playlists</li>
<li>Friend Requests (1)</li>
<li>Logout</li>
</ul></li>
<li>
<span>Messages <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Messages (1)</li>
<li>Compose New Message</li>
<li>Notifications (0)</li>
</ul></li>
<li>
<span>Videos <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Recent</li>
<li>Viewed</li>
<li>Featured</li>
<li>Top Rated</li>
<li>Commented</li>
</ul></li>
<li>
<span>Channels <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Recent</li>
<li >Viewed</li>
<li >Featured</li>
<li >Top Rated</li>
<li >Commented</li>
</ul></li>
<li>
<span>Groups <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Create New Group</li>
<li>All Time</li>
<li>Today</li>
<li>Yesterday</li>
<li>This Week</li>
<li>Last Week</li>
<li>This Month</li>
<li>Last Month</li>
<li>This Year</li>
<li>Last Year</li>
</ul></li>
<li>
<span>Upload <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Upload New Video</li>
<li>My Videos</li>
</ul></ul>
</div>
you can see a live demo at doctorwhohd.com
The problem im facing is this in normal all browsers except Firefox it looks like this when you hover over the items
In Firefox all versions i get this
Any help would be great! as this is a problem which i cannot seem to fix and im sure there is something im missing.
Your markup is really ugly for starters,
why have extra <span> tags in the top level <li> tags, why wrap your <img> tags with <em> and don't use for styling purposes.
Clean that up first.
Second, you have a lot of absolute and relative position styles that don't appear to be necessary. Have you tried styling your nav without the use of relative and absolute positioning.
The only place I see relative positioning being useful here is for the little arrow images.
Try that out.
You can give each #zone-bar ul li an explicit width (since it is the width of the li that is overrunning its content).
You may want to give each li an ID or class so that you can control their widths individually.