WordPress sub-menu will not appear visible and ins

2019-09-13 01:10发布

问题:

I would like the sub-menu to appear visible (like a normal sub-menu) instead of hiding under a scroll bar but I have become stuck

http://postimg.org/image/yqe0nz2p7/

CSS

.nav {
    float: right;
    display: inline-block;
    width: auto;
    position: relative;
}

.nav > ul > li {
    margin-right: 55px;
    overflow: visible;
}

.nav > ul > li > .sub-menu {
    position: absolute;
    padding-left: 0px;
    background-color: #fff;
    border-radius: 2px;
    border: 1px solid #ddd;
    z-index: 2;

}

HTML:

<nav class="nav" role="navigation">
                    <ul><li id="menu-item-18" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-18"><a href="http://www.ubietest.ubieportal.co.uk/web-design/">Web Design</a>
<ul class="sub-menu">
<li id="menu-item-992" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-992"><a href="http://www.ubietest.ubieportal.co.uk/terms/">Terms &#038; Conditions</a>     </li>
<li id="menu-item-993" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-993"><a href="http://www.ubietest.ubieportal.co.uk/terms/">Terms &#038; Conditions</a>    </li>
</ul>
</li>
<li id="menu-item-772" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-772"><a href="http://www.ubietest.ubieportal.co.uk/search-engine-optimization/">Search Optimization</a>
<ul class="sub-menu">
<li id="menu-item-994" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-994"><a href="http://www.ubietest.ubieportal.co.uk/terms/">Terms &#038; Conditions</a> </li>
</ul>
</li>
<li id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59"><a href="http://www.ubietest.ubieportal.co.uk/price-plans/">Price Plans</a></li>
<li id="menu-item-58" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-58"><a href="http://www.ubietest.ubieportal.co.uk/portfolio/">Portfolio</a></li>
<li id="menu-item-26" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-26"><a href="http://www.ubietest.ubieportal.co.uk/get-quote/">Get quote</a></li>
</ul>                   
</nav>

回答1:

You probably should set position: relative; to the element, that contains the dropdown menu <ul>. Right now the submenu is absolute to .nav element.

Also, there is overflow: visible; rule written for .nav > ul > li, you might want to check that as well. It creates the horizontal scrolling, and I think it's unnecessary.