Multi-level navigation menu that does not display level 3

the third level of my menu does not appear when you hover the 2nd level. I know that this is because it overflow:hiddenis written at level 2 ul, however, if I do overflow:visible, then the transition effect from max-heightdoes not work correctly. I tried to do overflow-y:hiddenwith overflow-x:visible, and this allows the transition to work, but it adds a horizontal scrollbar that you need to scroll to the right to see the third level menu. If you can solve this, I have another question with generosity on it, that I got only 1 bad answer: WAR QUESTION

My jsFiddle and related code below:

#menu li >  ul {
    position:absolute;
    top:auto;
    left:0;
    width:180px;
    max-height:0;
    box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
    visibility: hidden;
    z-index:99999;
    overflow:hidden;
    -webkit-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
     -moz-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
     -o-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
     -ms-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
     transition: max-height 0.2s ease, visibility 0s linear 0.5s;
  background: inherit !important;
}
#menu ul li:hover > ul {
    visibility: visible;
    max-height: 216px;
    transition-delay: 0s;
}
#menu li > ul > li > ul {
  position:absolute;
  top:0 !important;
  left:180px !important;
  width:180px;
  overflow:hidden;
  box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
  visibility:hidden;
}

HTML:

<nav id="menu">
    <ul id="main-nav">
        <li id="port"><a href="portfolio.html">Portfolio</a>
            <ul>
                <li id="regular"><a href="#">Regular</a>
                    <ul>
                        <li id="4col"><a href="#">4 columns</a>
                        </li>                        
                    </ul>
                </li>                
            </ul>
        </li>
        <li id="about" class="parent menu-item"><a href="">About</a>            
        </li>
    </ul>
</nav>
+3
1

overflow:visible ul. , .

#menu ul li > ul:hover {
    overflow:visible;
}
+2

Source: https://habr.com/ru/post/1539822/


All Articles