• Resolved jessicalane

    (@jessicalane)


    Hi,

    I’ve inherited a website with a custom theme, that has a simple top bar navigation. when you hover over the menu items, a drop down list appears. However this uses javascript, and i’d like it to function without for those users who disable javascript.

    I’ve got it to the point where (i think) it should be working, but it isn’t! the top level displays correctly but hovering has no effect- the drop down menu items aren’t appearing.

    My question is, is there a mistake with the following code, or is it correct but i need to change something somewhere else?

    Thank you in advance!

    (my main menu is registered as primary)

    code in header:

    <div id="linkbar-wrapper">
    <?php wp_nav_menu( array( 'container_class' => 'linkbar', 'theme_location' =>   'primary' ) ); ?>
    </div>

    code in style sheet:

    #linkbar-wrapper .linkbar #menu-main-menu li a
    {margin-top:95px;
    color:white;}
    #linkbar-wrapper .linkbar #menu-main-menu li a
    {padding-right:40px;}
    
    #linkbar-wrapper .linkbar #menu-main-menu li ul li a
    {display:none;
    padding:0;
    margin:0;}
    #linkbar-wrapper .linkbar #menu-main-menu li:hover ul li a
    {display:block;
    padding:0;
    margin:0;}

    There’s only one .js file for this site and i’ve commented out the section that refers to navigation as i’d like to do this without any javascript.

    I’m afraid i can’t link to the site as i’m working on a local host!

    Thanks again.

Viewing 1 replies (of 1 total)
  • Thread Starter jessicalane

    (@jessicalane)

    Issue resolved: I’d got my selectors wrong in the style sheet. It should have been:

    #linkbar-wrapper .linkbar #menu-main-menu li ul
    {display:none;
    padding:0;
    margin:0;}
    #linkbar-wrapper .linkbar #menu-main-menu li:hover > ul
    {display:block;
    padding:0;
    margin:0;}
Viewing 1 replies (of 1 total)

The topic ‘how to make a CSS drop-down menu without javascript’ is closed to new replies.