CSS nested UL menus, 4 levels [closed] - css

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm re-designing our administration menu (its currently vertical and LONG/CONFUSING) so I wanted to do a condensed horizontal one instead. I've been fiddling with this for a week now and I'm about to rip my hair out.
Here is a version you can see:
Horizontal Menu with 3 submenus
My CSS can be viewed here:
CSS File
Just a few quirks and I can't figure out how to fix them. I'll list them here separately:
Level 1 (the main buttons) are fine
Level 2 (Tina) looks fine
Level 3 (Tina/Inventory), the 3rd level options are BEHIND the level 2 ones. How do I get those in front of the level 2 stuff ? Ideally, I'd like level 3 to have the background color of #E4F683 and a hover color of #F6ED83 (for the Adjust On Hand, Component Report, Manage OOS)
Level 4 (Customers/Orders/Handpost), the level 4 stuff shows up when you hover over level 2... at that point level 3 should show, but level 4 should be hidden until you hover; same problem as above in that level 4 is behind level 3. Ideally, I'd like the background color of #E0F574 and a hover color of #AEC245 (Transaction, Shipping, Credit)
I really wouldn't mind if the level 3/4 weren't over level 2, but just lined up with them - this would fix the "behind/front" issue, but I can't seem to figure how what to change to make it work that way
I'd also like levels 2/3/4 to not be quite so high (there's quite a few more entries that I need to add), but I can't seem to figure out how to change my css to fix that
If someone could help me re-write my CSS to work how I really intend it to, I'll... well, I dunno, send you some cookies or something! I've looked and looked at this CSS til I'm cross-eyed!
I tried to post images to make it clearer but the system won't let me.
Mahalo!

I have created this Fiddle, removing all tables.
HTML:
<ul id="tinamenu">
<li><span class="mainmenu">Tina</span>
<ul>
<li>Admin
<ul>
<li>Calendar Import
</li>
</ul>
</li>
<li>Inventory
<ul>
<li>Adjust On Hand
</li>
<li>Component Report
</li>
<li>Manage OOS
</li>
</ul>
</li>
<li>Marketing
<ul>
<li>Count Incomplete
</li>
<li>Send Promo Email
</li>
<li>Validate Emails
</li>
</ul>
</li>
<li>Miscellaneous
<ul>
<li>FNWL Calendar
</li>
</ul>
</li>
<li>Orders
<ul>
<li>All Un-Processed
</li>
<li>Hand Post Transaction
</li>
<li>View Test Order
</li>
</ul>
</li>
<li>Personnel
<ul>
<li>Timecard Activity
</li>
</ul>
</li>
<li>Products
<ul>
<li>Categories
</li>
<li>FO Data
</li>
<li>New Product Checklist
</li>
<li>Price Table
</li>
<li>Sizes/Weights/Prices
</li>
<li>Specials
</li>
</ul>
</li>
<li>Reports
<ul>
<li>Carts
</li>
</ul>
</li>
<li>Web Site
<ul>
<li>Page Text
</li>
</ul>
</li>
<li>Personalize Menu
</li>
</ul>
</li>
<li><span class="mainmenu">Customers</span>
<ul>
<li>Orders
<ul>
<li>All Un-Processed
</li>
<li>Hand Post
<ul>
<li>Transaction
</li>
<li>Shipping
</li>
<li>Credit
</li>
</ul>
</li>
<li>Processed/Not Printed
</li>
<li>Awaiting Mail Payment
</li>
<li>Awaiting PayPal
</li>
<li>On Account
</li>
<li>Process Credit
</li>
<li>Search
</li>
<li>Search Order Notes
</li>
<li>Cancelled Orders
</li>
<li>Archived Orders
</li>
<li>Returns
</li>
<li>Damage Claims
</li>
<li>Outstanding RMAs
</li>
</ul>
</li>
<li>Customers
<ul>
<li>Email Customer
</li>
<li>Save Cart
</li>
<li>Database
</li>
<li>Search
</li>
<li>Search Emails
</li>
<li>Add
</li>
<li>Monthly Billing
</li>
<li>Set Non-HTML Status
</li>
<li>Combine Customer #s
</li>
<li>Chargebacks
</li>
<li>Prepaid Returns
</li>
</ul>
</li>
</ul>
</li>
<li><span class="mainmenu">Products</span>
<ul>
<li>New
<ul>
<li>Qualify Products
</li>
<li>Ingredient
</li>
<li>Non-Ingredient
</li>
<li>Price Table
</li>
<li>Non-Catalog
</li>
<li>Hidden
</li>
<li>New Product Checklist
</li>
</ul>
</li>
<li>Edit
<ul>
<li>Product
</li>
<li>Hidden
</li>
<li>Non-Catalog
</li>
<li>Sizes/Weights/Prices
</li>
<li>FO Data
</li>
<li>Pthalate/Vanillin
</li>
<li>Hide
</li>
</ul>
</li>
<li>Delete
<ul>
<li>Catalog
</li>
<li>Hidden
</li>
<li>Non-Catalog
</li>
</ul>
</li>
<li>Price Table
<ul>
<li>Manage
</li>
<li>Edit
</li>
<li>FO/CFO Check
</li>
<li>FO/CFO Catalog Price Check
</li>
</ul>
</li>
<li>Organic
<ul>
<li>Products
</li>
<li>Edit
</li>
</ul>
</li>
<li>Inventory
<ul>
<li>View OOS w/Sizes
</li>
<li>View OOS Products
</li>
<li>Manage OOS
</li>
<li>OOS Log
</li>
<li>Adjust On Hand
</li>
<li>Component Report
</li>
<li>By Vendor
</li>
<li>Vendor Receive Log
</li>
<li>By Category
</li>
</ul>
</li>
<li>Miscellaneous
<ul>
<li>Search Criteria
</li>
<li>Edit MSDS/Spec Sheet
</li>
<li>List MSDS/Spec Files
</li>
<li>Saponification Values
</li>
<li>Missing Images
</li>
<li>Upload Image
</li>
</ul>
</li>
<li>Specials
</li>
<li>Categories
</li>
<li>Clearance
</li>
<li>Extra Products
</li>
<li>On Order
</li>
</ul>
</li>
<li><span class="mainmenu">Warehouse</span>
<ul>
<li>Orders Shipped
</li>
<li>Shipping Charges
</li>
<li>Manage Receiving
</li>
<li>Products Needed
</li>
<li>Samples Received
</li>
</ul>
</li>
<li><span class="mainmenu">Marketing</span>
<ul>
<li>Promotional Emails
<ul>
<li>Validate Emails
</li>
<li>Send Promo Email
</li>
<li>Count Incomplete
</li>
<li>Search Mailing List
</li>
</ul>
</li>
</ul>
</li>
<li><span class="mainmenu">Web Site</span>
<ul>
<li>Page Text
</li>
</ul>
</li>
<li><span class="mainmenu">Reports</span>
<ul>
<li>Orders
<ul>
<li>Carts
</li>
</ul>
</li>
</ul>
</li>
<li><span class="mainmenu">Miscellaneous</span>
<ul>
<li>FNWL Calendar
<ul>
<li>Test Calendar
</li>
</ul>
</li>
</ul>
</li>
CSS & HTML on:
http://jsfiddle.net/andyjh07/cKnKL/
Please go to the misc menu at the end to see it in action (due to the small screen of jsFiddle)
Please feel free to nick the HTML and CSS codes as seems to be working :)

You may want to use relative and absolute positioning to move your sub-items and enable z-index to have them on top/below one another.
Here's an example of a mega menu I've used; take a look at how they display the sub items. It doesn't have more than one sub item, but the concept is the same. You may even want to use it to have all your sub items together, rather than use sub-sub items:
http://nettuts.s3.amazonaws.com/819_megamenu/demo/index.html

Related

How can I style the last of a serie of elements in css with a specific class?

In the website I'm working on the navigation menu is made by several nested lists, when one element is clicked on the <li> element with the page name acquires the .active class, if it belongs to a nested list all parent li elements above also acquire the .active class.
I'd like to be able to style the last <li> element with class .active since it corresponds to the currently open webpage.
I'm working with Omeka s content management system, which means that I can't use javascript or modify the HTML files, so I'm looking for a solution in pure CSS.
here is the menu structure:
`
<ul class="">
<li >
Introduction
</li>
<li>
level 1
<ul>
<li>
subpage
<ul>
<li>
sub-subpage
<ul>
<li>
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
here is when I'm on th page "sub-sub-page":
<ul class="">
<li >
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul>
<li class="active">
sub-subpage
<ul>
<li class="active">
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
`
I've tried to use li.active:last-of-type but it only select the last element of type li.
ul *{
color : #000;
text-decoration: none
}
ul .active ul li ul li ul li a{
color : #f00;
font-weight : bold;
}
<ul class="">
<li >
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul>
<li class="active">
sub-subpage
<ul>
<li class="active">
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
It appeared simpler than I first thought:
Given the current structure, from all nested active elements you need to select the li that only has an a element. To make it work in general (other than a list element) don't use the li element selector at all.
I added two differently nested examples in the snippet along with an ::after text...
.active > a:only-child { color: red }
.active > a:only-child::after { content: ' (active)' }
<ul class="">
<li>
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul>
<li class="active">
sub-subpage
<ul>
<li>
sub-sub-page
</li>
<li class="active">
sub-sub-page
</li>
<li>
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<br><br><br>
<ul class="">
<li>
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul>
<li>
sub-sub-page
</li>
<li>
sub-sub-page
</li>
<li class="active">
sub-subpage
</li>
<li>
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
<br><br><br>
<ul class="">
<li>
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul class="">
<li>
Introduction
</li>
<li class="active">
level 1
<ul>
<li class="active">
subpage
<ul>
<li class="active">
sub-sub-page
</li>
<li>
sub-sub-page
</li>
<li>
sub-subpage
</li>
<li>
sub-sub-page
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

How to add link to a collapsible item in a dropdown menu in Bootstrap 5?

I need to be able to add a link to "Home" and "Pages" when clicking it but also to collapse and show the li items from below.
I changed "#homeSubmenu" from a href with a link but when clicking it does not collapse.
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar">
<div class="sidebar-header">
<h3>Bootstrap Sidebar</h3>
</div>
<ul class="list-unstyled components">
<li class="active">
Home
<ul class="collapse list-unstyled" id="homeSubmenu">
<li>
Home 1
</li>
<li>
Home 2
</li>
<li>
Home 3
</li>
</ul>
</li>
<li>
About
</li>
<li>
Pages
<ul class="collapse list-unstyled" id="pageSubmenu">
<li>
Page 1
</li>
<li>
Page 2
</li>
<li>
Page 3
</li>
</ul>
</li>
<li>
Portfolio
</li>
<li>
Contact
</li>
</ul>
</nav>
</div>
Use data-bs-target for the Collapse and href for the link..
<li class="active">
Home
<ul class="collapse list-unstyled" id="homeSubmenu">
<li>
Home 1
</li>
<li>
Home 2
</li>
<li>
Home 3
</li>
</ul>
</li>

CSS selector within stacked lists

I am trying to style the nav in a template theme that I neither wrote nor picked. The nav uses lists in its structures and the children at various levels have the same class. I'm hoping someone can help me find the right CSS selector to pick the third level down. Here is the basic structure:
<nav class="nonbounce desktop vertical">
<ul>
<li class="item sub active">
<a class="itemLink" href="https://sitename/tools/" title="Tools">Tools</a>
<ul class="subnav">
<li class="subitem">
<a class="subitemLink" href="https://sitename/tools/outdoors/" title="Outdoors">Outdoors</a>
<ul class="subnav">
<li class="subitem">
<a class="subitemLink" href="https://www.safenready.net/tools/outdoors/mowers/" title="mowers">Mowers</a> THIS ONE!!!
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
What I need to do is grab the 3rd level down (called Mowers in example).
My ultimate goal is to style this level and move it vertically but first I need to be able to modify only that level with CSS.
This is a new site but I can provide the real site URL if that would help.
jc
You can try this
.subitemLink[title~="mowers"] {
font-size:20px;
}
<nav class="nonbounce desktop vertical">
<ul>
<li class="item sub active">
<a class="itemLink" href="https://sitename/tools/" title="Tools">Tools</a>
<ul class="subnav">
<li class="subitem">
<a class="subitemLink" href="https://sitename/tools/outdoors/" title="Outdoors">Outdoors</a>
<ul class="subnav">
<li class="subitem">
<a class="subitemLink" href="https://www.safenready.net/tools/outdoors/mowers/" title="mowers">Mowers</a> THIS ONE!!!
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>

Bootstrap issue with float/container classes

I am experiencing an issue with bootstrap in IE. It relates to the .pull-right class with just floats the <div> to the right.
This is a visual demonstation:
Chrome 28
IE10
The menu is construted using KendoUI and my site uses Bootstrap v.2.3.2 RC2. I am not aware of any compatibility issues with IE10. This issue does NOT present itself with IE9 or below though which is strange.
Here is the code:
<div class="main-ui-nav">
<div class="container">
<ul id="menu">
<li>
Customer
<ul>
<li>Customer Details</li>
</ul>
</li>
<li>
Products
<ul>
<li>View Products</li>
</ul>
</li>
<li>
Sites
<ul>
<li>Add Site</li>
<li>View Registered Sites</li>
</ul>
</li>
<li>
Payments
<ul>
<li>Invoices</li>
<li>Agreements</li>
<li>History</li>
<li>Oustanding</li>
<li>Statements</li>
</ul>
</li>
<li>
Notes
<ul>
<li>Create Note</li>
<li>Amend</li>
<li>View</li>
</ul>
</li>
<li class="pull-right">
Session Options
<ul>
<li>Exit Account</li>
<li>Logout</li>
</ul>
</li>
<li class="pull-right">Creation Options
<ul>
<li>Create Payment</li>
<li>Create Note</li>
<li>Create Invoice</li>
</ul>
</li>
</ul>
</div>
</div>
Thanks for your help in advance.
JS FIDDLE : http://jsfiddle.net/davcpas123/QFdTN/8/embedded/result/
This issue was due the KendoUI overriding the standard .clearfix classes.
To fix this I added :
.clearfix {
clear:both;
}
to my ui-full.css file.

CSS Friendly Adapters Menu Control Not working in IE

I was having some rendering issues with the old-style menu control getting Chrome to look correct, so I decided to switch and use the CSS Friendly Adapters (http://cssfriendly.codeplex.com/) to get my menu control to render as a list and hopefully have some more cross-browser consistency, well that hasn't worked either!
So I have styled my menus and they now work great with Chrome, Safari and Firefox, but not IE I have a basic horizontal list loaded from a datasource, with 1-13 items in the dynamic lists attached to them. In Chrome and Firefox now, after the menu is styled the dynamic menu items are appearing properly below the static menu items. But in IE(7/8) the dynamic menu items are appearing directly to the right of the currently hovered over static menu item (and with the first dynamic item behind the static menu item to the right of the current one)
Here is a screenshot of the menu working properly in Chrome:
http://i42.tinypic.com/2d3lom.png
And a screenshot of the same menu being hovered over in IE (in this case 8, but it looks the same in 7):
http://i39.tinypic.com/2vmc4kn.png
Here is the rendered HTML for the menu:
<div class="AspNet-Menu-Horizontal" id="ctl00_navMenu">
<ul class="AspNet-Menu">
<li class="AspNet-Menu-WithChildren AspNet-Menu-Selected">
Home
<ul>
<li class="AspNet-Menu-Leaf AspNet-Menu-ParentSelected">
Home
</li>
</ul>
</li>
<li class="AspNet-Menu-WithChildren">
<a href="javascript:void(0);" class="AspNet-Menu-Link">
Financial Systems</a>
<ul>
<li class="AspNet-Menu-Leaf">
Input Sales
</li>
<li class="AspNet-Menu-Leaf">
Upload Sales
</li>
</ul>
</li>
<li class="AspNet-Menu-WithChildren">
Reports
<ul>
<li class="AspNet-Menu-Leaf">
Prior
</li>
<li class="AspNet-Menu-Leaf">
Summary
</li>
<li class="AspNet-Menu-Leaf">
Monthly
</li>
</ul>
</li>
<li class="AspNet-Menu-WithChildren">
Administration
<ul>
<li class="AspNet-Menu-Leaf">
Shop Tracker
</li>
<li class="AspNet-Menu-Leaf">
Shop Upload
</li>
<li class="AspNet-Menu-Leaf">
Weekly Comp Metrics
</li>
<li class="AspNet-Menu-Leaf">
Weekly Comp Upload
</li>
<li class="AspNet-Menu-Leaf">
Estimate Maintenance
</li>
<li class="AspNet-Menu-Leaf">
User Maintenance
</li>
<li class="AspNet-Menu-Leaf">
Corporate Users
</li>
<li class="AspNet-Menu-Leaf">
Country ISO Code Maint
</li>
<li class="AspNet-Menu-Leaf">
Territory Rollup Maint
</li>
<li class="AspNet-Menu-Leaf">
Content Maintenance
</li>
<li class="AspNet-Menu-Leaf">
Edit System Message
</li>
<li class="AspNet-Menu-Leaf">
Menu Maintenance
</li>
<li class="AspNet-Menu-Leaf">
Change Password
</li>
</ul>
</li>
<li class="AspNet-Menu-WithChildren">
Help
<ul>
<li class="AspNet-Menu-Leaf">
<a href="help.aspx" class="AspNet-Menu-Link">
Help Menu</a>
</li>
</ul>
</li>
</ul>
</div>
And here is my CSS (same for IE and Chrome, but in the Chrome stylesheet I just add a gradient below this):
.AspNet-Menu li {color:#000000;line-height:20px;border:none;font-size:11px;font-weight:bold;}
.AspNet-Menu-WithChildren {width:150px;text-align:center;color:#FFFFFF;background:#940000;}
.AspNet-Menu-Selected {color:#000000;}
.AspNet-Menu-WithChildren a {color:#FFFFFF;}
.AspNet-Menu-Selected a {color:#000000;background:#FFCB0B;}
.AspNet-Menu-Leaf {background:#F0F0F0;width:150px;}
.AspNet-Menu-Leaf a {color:#000000;}
.AspNet-Menu-Leaf :hover, .AspNet-Menu-Leaf a :hover {background:#666666;color:#FFFFFF;}
Maybe try adding:
CSS
ul .AspNet-Menu-WithChildren ul {top:100%; float:none;}
I'm thinking that might force IE to put it where you need it to be. Not 100% sure, and wasn't able to try it on my local machine.

Resources