自定义动画animate()方法

Original 2018-12-29 10:52:48 258
abstract:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>自定动画</title> <script type="text/javascript" src="jquery-3.3.1.min.js">

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>自定动画</title>

<script type="text/javascript" src="jquery-3.3.1.min.js"></script>

<style type="text/css">

div{width: 200px;height: 200px;background: red;position: absolute;}

</style>

</head>

<body>

<script type="text/javascript">

$(document).ready(function(){

$('.bt1').click(function(){

$('p').animate({fontSize:'40px'},1500)

   })

$('.bt1').click(function(){

$('p').animate({fontSize:'14px'},1500)

   })


$('.bt2').click(function(){

$('div').animate({

//left:'500px',

//opacity:'0.3',   //多属性直接加

height:'toggle'  //预定义属性


},1500)

   })

  

})

 

</script>

<button class="bt1">点击字体变化</button>

<P>animate()方法创建自定义动画</P>

<button class="bt2">点击移动div</button>

<div></div>


</body>

</html>

总结:1.写法:animate({属性:'属性值'})

2.opacity: '0.4'   属性为透明度变化

3.width:'toggle'  toggle预定义值

Release Notes

Popular Entries