像这样的东西?
工作示例在这里:http: //jsfiddle.net/GaJBy/1/
请注意,它使用的是第 3 方 jQueryRotate 插件(http://www.nealfletcher.co.uk/js/jQueryRotate.js)。
CSS:
#outerDiv {
position: relative;
height: 300px;
width: 300px;
background: #FFF;
border: 1px solid #A0A0A0
}
#innerDiv {
position: absolute;
border: 1px solid #CCC;
width: 50px;
height: 50px;
vertical-align: middle;
text-align: center;
font-size: 36px
}
HTML:
<div id="outerDiv">
<div id="innerDiv">↓</div>
</div>
JS:
$("#innerDiv").click(function () { // Attach click listener
var duration = 500;
// If the square is not at the top, go down otherwise go back up
if (parseInt($(this).css("top")) > 0) {
finalPosition = 0;
startingAngle = 180;
endingAngle = 0;
} else {
finalPosition = $("#outerDiv").height() - $(this).height();
startingAngle = 0;
endingAngle = 180;
}
$(this).rotate({
angle: startingAngle,
animateTo: endingAngle,
duration: duration
});
$(this).animate({
top: finalPosition
}, duration);
});