0
I’m trying to make a menu similar to this:
Click here to see the example menu
What I did, I put a div
over the other using the position:absolute
and hid the div
responsible for the menu with a display:none
and in JS I am trying to apply an effect that makes it appear when clicked on a button, as well as in the example of the site. However, without success.
It doesn’t necessarily have to be with JS. It can be with JS, Jquery, CSS3 (I think this can be done with it too) etc.
Anyway, is there a "better way" to do this? Where am I going wrong?
function exibe(){
document.getElementById('nav').body= ??
}
html, body{
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#principal{
position: absolute;
width: 100%;
height: 100%;
}
#nav{
display: none;
position: absolute;
height: 100%;
z-index: 10;
}
#menu{
z-index: 11;
position: absolute;
}
<div id="principal">
<button id="menu" onclick="exibe()"> MENU </button>
<img src="http://i.stack.imgur.com/fr1br.png" style="width:100%; height:100%">
</div>
<div id="nav">
<img src="http://i.stack.imgur.com/UQXbV.png" style="height:100%">
</div>
in short, you want to make a menu off canvas?
– Tobias Mesquita
@Good tobymosque, yes and no. I’m not doing for a functional site. I’m doing this effect with two
divs
that have background images. About Off canvas, I’m getting to know now, based on what you said rsrs I researched and really is this kind of effect I want, but I wanted to know how I do it in hand. I am wanting to learn how to do things on my own and get rid of frameworks. If you or anyone can help me, I will be super grateful ;)– Zkk
Well I would use Bootstrap or Materialize, but you can take a look at jQuery Animate http://api.jquery.com/animate or http://www.w3schools.com/jquery/jquery_animate.asp
– user3010128
Very useful links, especially the w3schools for displaying the running code, I’ll look at it one by one, thank you!
– Zkk