我有3個divs,所有原本寬度爲33.333%。當點擊div時,我希望div擴大到80%,另外兩個未選定的div要崩潰到10%。我也希望這個過程是動畫。當我嘗試時,最右邊的列被推下頁面直到動畫結束。我怎樣才能讓這個過程流利?列動畫期間推下頁面
HTML:
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<title>
</title>
</head>
<body>
<div class="column" id="column1">
1
</div>
<div class="column" id="column2">
2
</div>
<div class="column" id="column3">
3
</div>
</body>
</html>
CSS:
body {
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px
}
.column {
height:100%;
float:left;
}
#column1{
width:33.33333%;
background:red;
}
#column2{
width:33.33333%;
background:white;
}
#column3{
width:33.33333%;
background:blue;
}
JS:
$(document).ready(function(){
$("#column1").click(function(){
$("#column1").animate({width:"80%"},{duration:1500,queue:false});
$("#column2").animate({width:"10%"},{duration:1500,queue:false});
$("#column3").animate({width:"10%"}, {duration:1500,queue:false});
});
$("#column2").click(function(){
$("#column1").animate({width:"10%"},{duration:1500,queue:false});
$("#column2").animate({width:"80%"},{duration:1500,queue:false});
$("#column3").animate({width:"10%"}, {duration:1500,queue:false});
});
$("#column3").click(function(){
$("#column1").animate({width:"10%"},{duration:1500,queue:false});
$("#column2").animate({width:"10%"},{duration:1500,queue:false});
$("#column3").animate({width:"80%"}, {duration:1500,queue:false});
});
});