Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    264
    Thanks
    49
    Thanked 1 Time in 1 Post

    Can't style Wordpress menu

    I have a Wordpress menu on my site generated by code:
    Code:
    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-primary' ) ); ?>
    When I assign the menu called "Categories" to the "Primary Menu" location, this generates front end code of:
    Code:
    <ul id="menu-categories" class="nav-primary">
        <li id="menu-item-910" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-910">
            <a href="http://steven.doig.com.au/category/environmental/">Environmental</a></li>
    </ul>
    The following CSS is not being applied:

    Code:
    #mainmenu {
        display: block;
    }
    #mainmenu ul.nav-primary ul {
    	list-style-type: none !important;
    	background-color: rgba(0,0,0,0.25) !important;
    	padding: 5px !important;
    	border-radius: 8px !important;
    	-moz-border-radius: 8px !important;
    	-webkit-border-radius: 8px !important;
    }
    #mainmenu ul.nav-primary ul li {
    	display: inline-block !important;
    	background-color: rgba(0,0,0,0.25) !important;
    	margin-right: 5px !important;
    	height: 32px !important;
    	padding-top: 8px !important;
    	border-radius: 8px !important;
    	-moz-border-radius: 8px !important;
    	-webkit-border-radius: 8px !important;
    }
    #mainmenu ul.nav-primary ul li a {
    	text-decoration: none !important;
    	color: #fff !important;
    	margin: 8px 14px 0 14px !important;
    }
    How do I style this menu when the ID being output on the front end is generated from the name of the menu in Appearance > Menus ?

    If I deploy this theme to the public, I will never be able to anticipate what the name of the menu will be, and the generated ID will always take precedence over the class.
    Last edited by SRD75; 07-23-2013 at 01:54 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Code:
    #mainmenu ul.nav-primary ul
    There's no <ul> inside the <ul> having class="nav-primary"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    SRD75 (07-23-2013)

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    264
    Thanks
    49
    Thanked 1 Time in 1 Post
    Thanks abduraooft.


  •  

    Tags for this Thread

    Posting Permissions

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