Slide a div in from off screen and then back on toggle

css, html, javascript, jquery

Solution

you also can toggle your div with a css transition. This is more quick because you only have to toggle a class. See my example jsfiddle to see what I mean.

http://jsfiddle.net/8Wkgf/1/

jquery

$('button').on('click', function(){
    $('#slider').toggleClass('open');

})

css

#slider{
    background:blue;
    height:100px;
    width:500px;
    position:relative;
    left:-520px;  
}
.open{
    left:0px !important;
}
.transition{

  -webkit-transition: left 0.3s ease-out;  /* Chrome 1-25, Safari 3.2+ */
     -moz-transition: left 0.3s ease-out;  /* Firefox 4-15 */
       -o-transition: left 0.3s ease-out;  /* Opera 10.50–12.00 */
          transition: left 0.3s ease-out;  /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */

}

html

<button>slide</button>
<div id="slider" class="transition"></div>

Problem

I am trying to move a div in from off screen and then back on toggle ``` $('a.show').on('click',function() { if($('#left-navi-designers').css('left')=='0px'){ $('#left-navi-designers').animate({left: '-100%'}, 1000); }else{ $('#left-navi-designers').animate({left:0}, 1000); } }); ``` That is what i have for the JavaScript. I have this for my CSS: ``` #left-navi-designers { height: 100%; position: fixed; background: #fff; width: 100%; left: -100%; } ``` This is my HTML: ``` <div id="left-icons"><a class="show" style="color:#999;">DUH!</a></div> <div id="left-navi-designers"> <div id="topNavigation"> <ul class="topLevelNavigation"> <a href=".topLevelNavigation" class="button"><li>DESIGNERS</li></a> <a href=".topLevelNavigation2" class="button"><li>EMERGING</li></a> <a href=".topLevelNavigation3" class="button"><li>STUDIOS</li></a> <a href=".topLevelNavigation4" class="button"><li>NEW FACES</li></a> <a href=".topLevelNavigation5" class="button"><li>EDITORS</li></a> <a href="#box1" class="button"><li>MEDIA KIT</li></a> <a href="#box1" class="button"><li>BEAUTY</li></a> <a href="#box1" class="button"><li>BRANDS</li></a> <a href="#box1" class="button"><li>MODELS</li></a> <a href="#box1" class="button"><li>PARTIES</li></a> </ul></div> ``` I'm very new to this and am just trying to get some things figured out. Here is the site i am playing on http://keithfrenchdesigns.com/RunwayMag/designers_main.html Thanks in advance!

Original source