Search code examples
csswordpressdrop-down-menumenusubmenu

submenu wont align to the menu when hovered


I'm having some problem with my menu and submenu when i hover on my menu the submenu wont align when hovered it floats on the left then show on the bottom of the first menu so when I select the last menu I cant select it. here's the reference picture.

http://prntscr.com/4trok1

HTML ( WORDPRESS )

<section class="twelve columns clearfix" style="background:transparent">
<div id="navcontainer">
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'header-menu' ) ); ?></div>
</section> 

CSS:

.menu {
    width:auto;
    float:left;
    display:block;
}

.children {
    display:none;
}

#navcontainer {
    display:inline;
    padding:0px;
    margin: 0px; /*-8px 0 0 10px;*/
    list-style:none;
    position:relative;
    z-index:1;
    float:left;
    height: 20px;
}

#navcontainer ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
    text-align: left;
}

#navcontainer ul li { 
    display: block;
    float: left;
}

#navcontainer ul li a {
    text-decoration: none;
    padding: .2em 1em;
    color: #b37032;
    background-color: #dbd2c1;
    width: 100%;
}

#navcontainer ul li ul li{
    display:block;
    width:auto;
    float: none;
    background:#edebd7;
}

#navcontainer ul li ul li a {
    background: transparent !important;
    color: #724e32;
    border-top: 0px !important;
    border-left: 0px !important;
    border-right: 0px !important;;
    -moz-border-radius: 0 0 0 0 !important;;
    -webkit-border-radius: 0 0 0 0 !important;;
    border-radius: 0 0 0 0 !important;;
    background-color: transparent !important;;
    opacity: 1 !important;; 
}

#navcontainer li:hover ul{

display:block;

}

#navcontainer ul li:hover a {
    color: #724e32;
    border-top: 1px solid #694b0a;
    border-left: 1px solid #694b0a;
    border-right: 1px solid #694b0a;
    -moz-border-radius: 5px 5px 0 0;
    -webkit-border-radius: 5px 5px 0 0;
    border-radius: 5px 5px 0 0;
    background-color: #edebd7;
    opacity: 0.5;
}

#navcontainer ul li a:hover {
    color: #fff;
    background-color: #d3c096;
}


#navcontainer li:hover ul.children { 
    left:0; 
    top:18px; 
    background:#edebd7; 
    color:#724e32; 
    padding:5px; 
    position:absolute;
    border-left:1px solid #694b0a; 
    border-right:1px solid #694b0a; 
    border-bottom:1px solid #694b0a; 
    white-space:nowrap; 
    width:160px; 
    height:auto; 
    z-index:300; 
    -moz-border-radius:0 0 5px 5px; 
    -webkit-border-radius:0 0 5px 5px; 
    border-radius:0 0 5px 5px;

}

#navcontainer ul li ul li:hover {
    color: #fff;
    background-color: #d3c096;
}

#navcontainer ul li ul li a:hover {
    color: #fff;
    background-color: #d3c096;
}

#navcontainer ul li ul li:hover a{
    color: #fff;
    background-color: transparent;
}

Solution

  • replace this class in your css file and everything should be fine:

    #navcontainer li:hover ul.children { 
        top:18px; 
        background:#edebd7; 
        color:#724e32; 
        padding:5px; 
        position:absolute;
        border-left:1px solid #694b0a; 
        border-right:1px solid #694b0a; 
        border-bottom:1px solid #694b0a; 
        white-space:nowrap; 
        width:160px; 
        height:auto; 
        z-index:300; 
        -moz-border-radius:0 0 5px 5px; 
        -webkit-border-radius:0 0 5px 5px; 
        border-radius:0 0 5px 5px;
    
    }
    

    the left:0 propriety was the problem. Nothing else :)