I'd like to have my Bootstrap menu automatically drop down on hover, rather than having to click the menu title. I'd also like to lose the little arrows next to the menu titles.
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- How to add a “active” class to a carousel first el
- Add animation to jQuery function Interval
- jQuery hover to slide?
Just want to add, that if you have multiple dropdowns (as I do) you should write:
And it'll work properly.
Simply customize your CSS style in three lines of code
Also added margin-top:0 to reset the bootstrap css margin for .dropdown-menu so the menu list dosen't dissapear when the user hovers slowly from drop down menu to the menu list.
This works for WordPress Bootstrap:
So you have this code:
Normally it works on a click event, and you want it work on a hover event. This is very simple, just use this JavaScript/jQuery code:
This works very well and here is the explanation: we have a button, and a menu. When we hover the button we display the menu, and when we mouseout of the button we hide the menu after 100 ms. If you wonder why I use that, is because you need time to drag the cursor from the button over the menu. When you are on the menu, the time is reset and you can stay there as many time as you want. When you exit the menu, we will hide the menu instantly without any timeout.
I've used this code in many projects, if you encounter any problem using it, feel free to ask me questions.
Use this code to open the submenu on mousehover (desktop only):
And if you want the first level menu to be clickable, even on mobile add this:
The submenu (dropdown-menu) will be opened with mousehover on desktop, and with click/touch on mobile and tablet. Once the submenu was open, a second click will let you open the link. Thanks to the
if ($(window).width() > 767)
, the submenu will take the full screen width on mobile.