【发布时间】:2012-10-30 19:02:32
【问题描述】:
我希望 .left div (width:20%;) 滑入 .right div (初始宽度:100%;) 并让 .right div 在动画上调整为 width:80%;
基本上,滑动一个 div 并让另一个调整大小。
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);
});
【问题讨论】: