jquery - Slide div out of screen and other div into screen at the same time -
i'm building mobile web app (apk not link) , know how compile. i'd give real app feel (effects).
i have far:
is there way make whole div slide left while div slides right fill in place when click category? i'm looking simple code so, i'll take anything.
thanks!
based on comment here basic code started.
$('.button').click(function() { if ($(this).hasclass('button-right')) { $('.block1').css('marginleft', '-100%') } else { // hasclass button-left $('.block1').css('marginleft', '0%') } })
html, body { height: 100vh; margin: 0; padding: 0; background-color: green; } div { display: flex; height: 100%; } .container { position: relative; display: flex; flex: 1; } .blocks { display: flex; justify-content: center; align-items: center; flex: 1; min-width: 100%; transition: 0.3s ease; } .block1 { margin-left: 0; background-color: red; } .block2 { background-color: yellow; } .button { position: absolute; top: 50%; transform: translatey(-50%); display: flex; justify-content: center; align-items: center; width: 30px; height: 30px; border-radius: 100%; color: white; background-color: black; font-variant: small-caps; font-size: 14px; font-weight: bold; cursor: pointer; } .button:hover {background-color: green;} .button-left { left: 10px; } .button-right { right: 10px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container"> <div class="blocks block1">div 1 (left)</div> <div class="blocks block2">div 2 (right)</div> <div class="button button-left">l</div> <div class="button button-right">r</div> </div>
fiddle
Comments
Post a Comment