abstract:<!DOCTYPE html><html><head> <title>jQuery的動畫效果--自定義動畫</title> <meta charset="utf-8"> <script type="text/javascript"
<!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">
body{margin: auto; text-align: center;}
div{width: 100px;height: 500px;background:#f93;position: absolute; color: #fff;}
button{background: lightblue;}
ul{list-style: none; text-align: left; margin-left: -25px;}
li{margin-top: 20px;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('p').hide()
$('#btn1').click(function(){
$('p').slideToggle()
})
$('#btn2').click(function(){
$('div').fadeToggle()
})
$('.but1').click(function(){
$('p').animate({fontSize:'40px'},1500)
})
$('.but3').click(function(){
$('p').animate({fontSize:'15px'},1500)
})
//同時操作多個css屬性
//使用預(yù)定義的值 show hide toggle
$('.but2').click(function(){
$('div').animate({
width:'toggle'
},1500)
})
$('#right').click(function(){
$('.box1').animate({left:'+1000px'},3000)
$('.box1').animate({fontSize:'20px'},1000)
})
$('#left').click(function(){
$('.box1').animate({left:'+300px'},3000)
$('.box1').animate({fontSize:'23px'},1000)
})
$('#stop').click(function(){
$('.box1').stop(true)
})
})
</script>
</head>
<body>
<button id="btn1">上滑/下滑切換顯示</button>
<button class="but1">點擊字體放大</button>
<button class="but3">點擊字體縮小</button><br>
<p>jQuery中我們使用 animate()方法創(chuàng)建自定義的動畫</p>
<button id="btn2">淡入淡出切換</button>
<button class="but2">點擊收縮/伸展div</button>
<!-- 點擊右移按鈕,div右移,點擊停止按鈕當(dāng)前效果停止 -->
<button id="right">右移</button>
<button id="left">左移</button>
<button id="stop">停止</button>
<div class="box1">
<ul>
<li>php中文網(wǎng)</li>
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
<li>jQuery</li>
<li>layui</li>
<li>DOM</li>
<li>Ajax</li>
<li>PHP</li>
</ul>
</div>
</body>
</html>
Correcting teacher:滅絕師太Correction time:2019-01-08 16:13:03
Teacher's summary:測試的比較全面,建議帶上實戰(zhàn)案例練習(xí)奧!嘗試一下,找點類似導(dǎo)航動態(tài)效果等……