摘要:<!DOCTYPE html><html><head> <title>jQuery的動(dòng)畫(huà)效果--自定義動(dòng)畫(huà)</title> <meta charset="utf-8"> <script type="text/javascript"
<!DOCTYPE html>
<html>
<head>
<title>jQuery的動(dòng)畫(huà)效果--自定義動(dòng)畫(huà)</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)
})
//同時(shí)操作多個(gè)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">點(diǎn)擊字體放大</button>
<button class="but3">點(diǎn)擊字體縮小</button><br>
<p>jQuery中我們使用 animate()方法創(chuàng)建自定義的動(dòng)畫(huà)</p>
<button id="btn2">淡入淡出切換</button>
<button class="but2">點(diǎn)擊收縮/伸展div</button>
<!-- 點(diǎn)擊右移按鈕,div右移,點(diǎn)擊停止按鈕當(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>
批改老師:滅絕師太批改時(shí)間:2019-01-08 16:13:03
老師總結(jié):測(cè)試的比較全面,建議帶上實(shí)戰(zhàn)案例練習(xí)奧!嘗試一下,找點(diǎn)類(lèi)似導(dǎo)航動(dòng)態(tài)效果等……