I am wondering if there's a tutorial to display a context-like menu when hovering a button, this is very similar to Google Plus onHover menu effect seen below:
Any tutorial on this is appreciated, thanks!
I am wondering if there's a tutorial to display a context-like menu when hovering a button, this is very similar to Google Plus onHover menu effect seen below:
Any tutorial on this is appreciated, thanks!
You might find the below link helpful:
http://medialize.github.io/jQuery-contextMenu/demo/trigger-hover-autohide.html
The best way in my opinion is using pure css
CSS:
.button {
position: relative;
}
.button .hovermenu {
position: absolute;
top: 25px;
left: 0px;
display: none;
}
.button:hover .hovermenu {
display: block;
}
HTML:
<ul>
<li class="button">
This has a hovermenu!
<div class="hovermenu">
<ul>
<li>Submenu item</li>
</ul>
</div>
</li>
</ul>
This will give hundreds of tutorials about what you want,
you can create such a menu with simple css only, have a look here,
http://line25.com/tutorials/how-to-create-a-pure-css-dropdown-menu
hope this helps you
ok you've got two event optins here, here's the OBVIOUS one;
$( "img" ).hover(
function() {
showMenu(); //hyperthetical function to show whatever
}, function() {
hideMenu();//hyperthetical function to show whatever
});
You don't need a tutorial to do that. It's simple css.
//Your button
<input type="button" class="btn" />
//Your div that contains the contextual-like menu
<div class="contextualMenu">
your contextual menu goes here
</div>
//And the css code is (menu is hidden by default and shows up only when you hover the button)
.contextualMenu{display:none;}
.btn:hover .contextualMenu{display:block;}
Hope this is useful for you. Cheers!
Copying the very good method used in Bootstrap (this is how I'd do it):
Have a container, a trigger and a menu.
HTML
<div class="dropdown_container">
<a class="dropdown_trigger">Button</a>
<ul class="dropdown_menu">
<li><a>...</a></li>
<li><a>...</a></li>
...
</ul>
</div>
CSS
.dropdown_container { position: relative; }
.dropdown_trigger { display: block; }
.dropdown_menu { position:aboslute; top: 100%; display: none; }
.show_dropdown .dropdown_menu { display: block; }
JS
// On click
$('.dropdown_trigger').click( function() {
$(".dropdown_menu").addClass("show_dropdown");
});
// On hover
$('.dropdown_trigger').hover( function() {
$(".dropdown_menu").addClass("show_dropdown");
});
// Or add the css directly
$('.dropdown_trigger').hover( function() {
$(".dropdown_menu").css("display", "block");
});