javascript - JS Slide toogle sidebars out and expand content div -
i want slide out both sidebars , expand width of middle content div @ same time , on again click want toogle original.
what tried far
$('.headbar').click(function () { $(".leftside").animate({width: 'toggle'}); $( ".rightside" ).animate({ width: "toggle" }, 300, function() { $(".content").animate({width: '1200px'}); }); });
my problems
headbar flashing when animation start (but guess css bug)
content not toggle original
my concept understanding
i approach using css class transition effect toggled jquery instead of using jquery animate
function.
working demo:
$(document).ready(function() { $('body').on('click', '.headbar', function(){ $('body').toggleclass('expanded'); }); });
.headbar { width: 100%; background: #303030; background-repeat: repeat; background-size: 38px 133px; height: 40px; background-position: 0px 39px; box-shadow: 0px 1px 5px; position: fixed; z-index: 1000; margin-top: -40px; } .leftside { position: fixed; left: 2%; top: 100px; height: 500px; width: 13%; background-color: rgba(123, 123, 123, 0.95); } .rightside { position: fixed; right: 2%; top: 100px; height: 500px; width: 13%; background-color: rgba(123, 123, 123, 0.95); } .scrollable { position: relative; top: 20px; min-height: 700px; width: 70%; margin: 0 auto; box-shadow: 0px 1px 5px; background: white; } /* ===================== */ /* expanded transition /* ===================== */ .leftside, .rightside, .scrollable { transition:0.3s; } body.expanded .scrollable { width:100%; } body.expanded .leftside { left: -100%; } body.expanded .rightside { right: -100%; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="headbar"></div> <div class="leftside"></div> <div class="rightside"></div> <div class="scrollable"></div>
Comments
Post a Comment