0
I would like to apply the following function in a project.
When clicked on the button (that applied will be the menu button) the entire content of the site that is inside the div CONTEUDO-MOVEL
should go left hiding a part of the content, because the Section that it encounters is with OVERFLOW:HIDDEN
and the content of div class="MENU"
would be visible.
This is the first action.
After that, if the user clicks off the DIV CLASS="MENU"
, the class MOVE-LEFT
is removed and the site goes back to its initial state, hiding the side menu.
Follows jsfiddle structure and link:
HTML:
<section id="conteudo"><a href="#" class="move">MENU</a>
<div id="conteudo-movel">
<div class="cont"></div>
<div class="menu"></div>
</div>
</section>
CSS:
#conteudo
{position:absolute;relative;width:500px;height:200px;background:#f6f6f6;overflow:hidden;}
#conteudo-movel
{position:absolute;width:700px;height:100px;background:#000;left:0;}
.cont{width:500px;background:#c1c1c1;height:50px;position:relative;float:left;}
.menu{width:200px;background:#c1c1c1;height:50px;position:relative;float:left;}
.move{left:0;}
.move-left{left:-200px!important;}
Javascript:
$( "a.move" ).click(function() {
$( "#conteudo-movel" ).addClass( "move-left" );
$( "this" ).removeClass( "move-left" );
});
as @Eduardosilva replied, this can be done with off-canvas. but if you are interested in a ready-made implementation, you can check the following link: http://foundation.zurb.com/docs/components/offcanvas.html
– Tobias Mesquita