Last active
April 4, 2019 00:29
-
-
Save SimonPadbury/6774640 to your computer and use it in GitHub Desktop.
This is a simple supplement for Bootstrap 3 to transform the navbar so that the dropdown menu appears on hover instead of on click. No need to modify the Bootstrap 3 js or css at all – simply add this js and css below to your js and css files that are <head> linked *after* the Bootstrap 3 js and css files. Styles for both .navbar-default and .na…
Perfect! Thanks so much!
Thank you!
Thanks a ton :)
Hi Simon - thank you for this great gist, works very well!
I have two small reports:
- The recently added line 29 in hovernav.js uses backticks instead of single quotes, which should work in ES2015 but is inconsistent with the rest, and I guess it just happened by accident anyway.
- As Chrome interprets middle-click as click event as well, opening a new tab with middle click on a top-level menu item also reloads the page in the current tab. That's more of an observation though, I think it's fine for you to leave it like it is. (I'll have to fix it internally for my project though, and if I can come up with a good generic solution I'll let you know :))
Update:
Regarding the 2nd report I went the short road and rewrote the click binding as follows ...
$('.hovernav a').mousedown(function(event) {
if(event.which === 1) {
window.location = this.href;
}
});
(But I don't think this is a good generic solution, just mentioning it for the record. :))
Is it an easter egg on 29th line of js? :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot 😃