I would like to apply the following function in a project.
When clicked on the button (which applied, it will be the menu button) the entire content of the site that is inside the CONTEUDO-MOVEL
div should go to the left hiding a part of the content because the section it is with OVERFLOW:HIDDEN
and the contents of div class="MENU"
would be visible.
This is the first action.
After this, if the user clicks out of DIV CLASS="MENU"
, the MOVE-LEFT
class is removed and the site returns to its initial state, hiding the side menu.
Follow jsfiddle's 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" );
});