I’d like the .left div (width:20%;) to slide into the .right div (initial width:100%;) and have the .right div resize on animation to width:80%;
Basically, slide in a div and have the other resize.
HTML
<div class="container">
<div class="left">
<p>left</p>
</div>
<div class="right">
<p>right content</p>
<p class="showLeft">[Show left div]</p>
</div>
CSS
html, body {
width:100%;
height: 100%;
margin: 0;
}
.container {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.left, .right {
float: left;
height: 100%;
}
.left {
background: green;
width: 20%;
display: none;
}
.right {
background: red;
width: 100%;
}
.showLeft {
cursor: pointer;
}
JS
$('.showLeft').click(function(){
$('.right').animate({width: '80%'},350);
$('.left').animate({width:'toggle'},350);
});
Unfortunately,…Actually, it exists! It’s in the specs:width:'toggle'doesn’t existI really don’t know why it’s not working here. And
showseems buggy (little flashy demo).Anyway, you can set the initial width to 0:
And use this edited function:
Demo