Reputation: 4166
Using .hide()
and .fadeIn(200)
is creating this jumpy effect, which I don't want.
So I looked at this post which talked about using visibility to show/hide elements. I feel like using visibility might be the key. The only thing is I want the menu icon and "Problems" to replace each other, and w/out the display
set to none
, they are stacked on top of each other like so:
So if I were to use visibility, there would be gaps created by the hidden element.
HTML
<div id="Menu-Header" class="header">
<button id="Menu-Button" type="button" class="btn btn-default btn-lg button-menu" aria-label="Menu">
<span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>
<h1>Problems</h1>
</button>
</div>
CSS
#Menu-Header h1 {
font-weight: 300;
text-align: center;
text-transform: uppercase;
display: none;
}
jQuery
$('#Menu-Button').on('mouseenter cick', function(){
$(this).children('.glyphicon-menu-hamburger').hide();
$(this).children('h1').fadeIn(200);
});
$('#Menu-Button').on('mouseleave', function(){
$(this).children('h1').hide();
$(this).children('.glyphicon-menu-hamburger').fadeIn(200);
});
Upvotes: 1
Views: 74
Reputation: 5766
If you add a static height to #Menu-Button
the jumpy effect disappears. See updated jsfiddle - https://jsfiddle.net/utuj88gg/1/
Upvotes: 1