abstrait:<!DOCTYPE html><html><head> <title>jQuery的動畫效果--自定義動畫</title> <meta charset="utf-8"> <script type="text/javascript" src="jq
<!DOCTYPE html>
<html>
<head>
<title>jQuery的動畫效果--自定義動畫</title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
div{width: 200px;height: 200px;background:blue;position: absolute; color: #fff;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('.but1').click(function(){
$('p').animate({fontSize:'40px'},1500)//屬性名稱font-size 一律改成駝峰寫法:fontSize
})
//同時操作多個css屬性
//使用預(yù)定義的值 show hide toggle
$('.but2').click(function(){
$('div').animate({
// left:'400px',//如果想對元素位置進行一個位移,那么我們需要給當(dāng)前元素設(shè)置一個position例如:
// opacity:'0.3',
// height:'400px',
// width:'400px'
width:'toggle'
},1500)
})
$('#right').click(function(){
$('.box1').animate({left:'+500px'},3000)
$('.box1').animate({fontSize:'30px'},500)
})
$('#stop').click(function(){
$('.box1').stop(true)
})
})
</script>
</head>
<body>
<!-- 點擊右移按鈕,div右移,點擊停止按鈕當(dāng)前效果停止 -->
<button id="right">右移</button>
<button id="stop">停止</button>
<div class="box1"> php中文網(wǎng)</div>
</body>
</html>
Professeur correcteur:天蓬老師Temps de correction:2018-12-23 10:56:21
Résumé du professeur:作業(yè)寫的不錯,最好能記錄一上animate中的left,height,width的作用