Keeping dropdown menu active (visible) even after hover out

前端 未结 4 511
滥情空心
滥情空心 2021-01-07 05:53

My sub menu disappears immediately after I move my mouse pointer to scroll towards the sub menu. Feel like I have screwed my CSS somewhere. I could not figure out after seve

4条回答
  •  盖世英雄少女心
    2021-01-07 06:38

    Here's a way to do it (it's more of a trick):

    http://jsfiddle.net/zj8krh95/5/

    #topnav ul li:hover {
        padding-bottom: 10px;
        margin-bottom: -10px; /* so that the menubar's height stays the same */
    }
    #topnav ul li:hover ul {
        margin-top: -10px; /* so that the menu opens at the right position */
    }
    

    Basically, on hover, i extend the menu item's height so that no mouseout is trigger when i move down to the menu.

提交回复
热议问题