I am looking to create CSS that will display these links below in “left to right” divs and when action like “rollover” happens the appropriate sub-menu’s will appear right below the menu they just rolled over.
Here is the KEY. This menu will be “Dynamically Loaded” from wordpress database so I need to know how to style the “main menus” and then on the rollover of each menu the dropdown will appear below in the right spot. But I can’t hard coded names as the menu items will change etc.. does this make sense?
Here is one dynamic example loaded from a a wordpress database.
THIS CODE BELOW:
<?
require('wordpress/wp-blog-header.php');
?>
<div class="access">
<?php wp_nav_menu(); ?>
</div>
LOADS THE FOLLOWING HTML BELOW:
<div class="access">
<div class="menu-papamenu-container"><ul id="menu-papamenu" class="menu"><li id="menu-item-45" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-45"><a href="?p=love">Home</a>
<ul class="sub-menu">
<li id="menu-item-46" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-46"><a href="?p=Happy">Happy</a></li>
<li id="menu-item-47" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-47"><a href="?p=coolBeans">Cool Beans</a></li>
<li id="menu-item-49" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-49"><a href="?p=SoHappy">So Happy</a></li>
</ul>
</li>
<li id="menu-item-48" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-48"><a href="?p=Contact">Contact Us</a>
<ul class="sub-menu">
<li id="menu-item-50" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-50"><a href="?p=Address">Address</a></li>
<li id="menu-item-51" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-51"><a href="?p=Phone">Phone</a></li>
<li id="menu-item-52" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-52"><a href="?p=Email">Email</a></li>
</ul>
</li>
<li id="menu-item-53" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-53"><a href="?p=About">About Us</a>
<ul class="sub-menu">
<li id="menu-item-54" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-54"><a href="?p=Company">Company</a></li>
<li id="menu-item-55" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-55"><a href="?p=CompanyAddress">Company Address</a></li>
</ul>
</li>
</ul></div></div>
But how can I add CSS to give it the proper navigation drop downs etc?
The OUTPUT without CSS can be seen here.
I tend to make the top level li’s
inline-block
s for this and then make the sub-menusblock
s. Then just use of the css :hover selector and some absolute positioning of the sub-menus does the job. Made a fiddle for you to demonstrate.http://jsfiddle.net/jaredkhan/EuH8P/1
http://jsfiddle.net/UVkGG/