SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    wordpress drop down menu

    So, I've built sites with dynamic vertical navigation menus. However, I can't quite figure out how to create a dynamic drop down menu in wordpress. You can see on here that I am calling the Main Nav menu twice here. I did it once styled and a second time with no styling. I did this to show that the code is calling the navigation properly but that it won't show when the CSS is applied.

    http://www.connect4webdesign.com/

    So, this is what I did.


    1) Create the pages (Home > About us, Services)
    2) Created the menu 'Main Nav'
    3) Added the code to the Header



    CODE

    Code:
    <?php if (function_exists('dynamic_sidebar')) : else : ?>
      		<?php endif; ?>
    
    
    
    <ul id="nav">
    
    
    <?php wp_nav_menu(array('menu' => 'Main Nav')); ?>
    
    
    </ul>
     
     
     <ul>
    
    <?php wp_nav_menu(array('menu' => 'Main Nav')); ?>
    
    </ul>
    
    4) Put in the CSS that I have working properly on another site to test this. http://binghamdentalutah.com/
    
    
    #nav{
    	list-style:none;
    	font-weight:bold;
        background:#9C1F1B url("http://Connect4WebDesign.com/wp-content/themes/Connect 4 WP/images/Nav background.png") repeat-x;
    	height:66px;
    	margin-top:-10px;
    	margin-bottom:0px;	
    }
    
    
    #nav li{
    	float:left;
    	margin-right:0px;
    	position:relative;
    	font-size:20px;
    	padding-right:15px;
    
    	
    	
    }
    
    #nav a{
    	display:block;
    	padding:5px;
    	color:#0169dc;
    	text-decoration:underline;
    	
    }
    
    
    #nav a:hover{
    	text-decoration:underline;
    	
    		
    	color:#FFFFFF;
    }
    
    
    
    
    
    
    
    /*--- DROPDOWN ---*/
    
    
    #nav ul{
    	background:#fff; /* Adding a background makes the dropdown work properly in IE7+. Make this as close to your page's background as possible (i.e. white page == white background). */
    	background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
    	list-style:none;
    	position:absolute;
    	left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
    }
    
    
    
    #nav ul li{
    	padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
    	float:none;
    	font-size:18px;
    }
    
    
    
    
    #nav ul a{
    	white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
    	color:#FFFFFF;
    }
    
    
    
    
    #nav li:hover ul{ /* Display the dropdown on hover */
    	left:-40px; /* Bring back on-screen when needed */
    }
    
    
    
    
    #nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
    	background:#06C;
    	text-decoration:underline;
    	border:thin #ffffff solid;
    	color:#FFFFFF;
    	
    }
    
    
    
    
    #nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
    	text-decoration:none;
    	
    }
    
    
    
    
    #nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
    	background:#0066FF;
    }
    
    #nav li:hover ul li a:active{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
    	background:#8cc63f;
    }
    Well, if anyone can toss me some helpers here it would be great. thx
    Last edited by TechnoBear; Oct 5, 2012 at 04:26. Reason: Code tags added

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    7 Thread(s)
    You have a slight mistake here:

    Instead of

    Code:
    #Testnav li:hover ul { 
    	left:-40px;
    }
    use this

    Code:
    #Testnav li:hover ul li { 
    	left:-40px;
    }
    It's the LIs that need to be moved back in place, not the UL.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx you rock and that worked perfect.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •