当前位置: 代码迷 >> 综合 >> JQurey--动画
  详细解决方案

JQurey--动画

热度:66   发布时间:2023-12-13 22:22:25.0
animate函数实现div的平移缩放动画

bottom,left,right,top平移
height+=缩放
js

$(document).ready(function(){
    $("button").click(function(){
    $("div").animate({
    bottom:'100px',height:'+=100px',width:'+=100px'});});
});
</script> 

html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script> 
$(document).ready(function(){
    $("button").click(function(){
    $("div").animate({
    bottom:'100px',height:'+=100px',width:'+=100px'});});
});
</script> 
</head><body>
<button>开始动画</button>
<p>默认情况下,所有的 HTML 元素有一个静态的位置,且是不可移动的。 
如果需要改变为,我们需要将元素的 position 属性设置为 relative, fixed, 或 absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div></body>
</html>

参考菜鸟教程