我有两个问题,如何将缓动效果用于展开onclick的div,以及淡入淡出对其中的元素的影响?
1)我有一个div扩展onclick,(.panel)如何使用缓动,因此它以平稳的方式打开?
2)如何扩展div(.panel)内的ul列表在div展开后的几毫秒内淡入?
<div id="effect" class="mores" style="background-color: brown">
<div class="panel">click
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</div>
JS
var next_move = "expand";
$(document).ready(function() {
$(".panel").click(function() {
console.log(next_move);
var css = {};
if (next_move == "expand") {
css = {
width: '210px',
height: '170px'
};
next_move = "shrink";
} else {
css = {
width: '30px',
height: '20px'
};
console.log('hi');
next_move = "expand";
}
$(this).animate(css, 200);
});
});
.panel {
width: 30px;
height: 21px;
overflow: hidden;
color:white;
background-color: grey;
}
.panel ul {
margin-left:10%;
color:white;
}
.mores {
width: 210px;
height: 170px;
overflow: hidden;
}
这里是小提琴JSFiddle
非常感谢
谢谢你,这正是我需要的。 – 2014-10-07 19:59:52