摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jq自定義動(dòng)畫</title> <script type="text/javascript" src="jque
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jq自定義動(dòng)畫</title> <script type="text/javascript" src="jquery.js"></script> <style type="text/css"> *{margin: 0;padding:0;} .box{background-color: #F8F8F8;width: 100%;height: 70px;} .box1{width: 1200px;margin: 0 auto;} ul{list-style: none;} li{float: left;margin-left: 100px;font-size: 16px;line-height: 70px;} a{color: #13D1BE;position: relative;position: relative;} a:visited{color:#13D1BE;} a:hover{color:#13D1BE;} </style> <script type="text/javascript"> $(document).ready(function(){ $('li').mouseover(function(){ $(this).animate({fontSize:'20px'},1200).stop() }) $('li').mouseout(function(){ $(this).animate({fontSize:'16px'},600).stop() }) }) </script> </head> <body> <div> <div> <ul> <li> <a href="">發(fā)現(xiàn)音樂</a> </li> <li> <a href="">我的音樂</a> </li> <li> <a href="">朋友</a> </li> <li> <a href="">商城</a> </li> <li> <a href="">音樂人</a> </li> <li> <a href="">下載客戶端</a> </li> </ul> </nav> </div> </body> </html>
筆記:
jq自定義動(dòng)畫
animate({params},speed,fn)
必需的params 參數(shù)定義形成動(dòng)畫的 css 屬性.
可選的 speed 參數(shù)規(guī)定效果的時(shí)長.
可以同時(shí)操作多個(gè)css屬性,中間用逗號(hào)隔開,也可以使用預(yù)定義的值
show,hide,toggle.
如果想要對(duì)元素位置進(jìn)行一個(gè)位移,需要給元素一個(gè)定位才行
停止動(dòng)畫
stop(stopAll,goToEnd)
默認(rèn)情況下stop()會(huì)清除在被選元素上指定的當(dāng)前動(dòng)畫
可選參數(shù) stopAll 規(guī)定是否應(yīng)該清除動(dòng)畫隊(duì)列,默認(rèn)是false,僅停止活動(dòng)的動(dòng)畫
可選參數(shù) goToEnd() 規(guī)定是否立即完成當(dāng)前動(dòng)畫,默認(rèn)是false
批改老師:滅絕師太批改時(shí)間:2019-03-11 11:31:02
老師總結(jié):練習(xí)和筆記都非常清楚,完成的不錯(cuò)!繼續(xù)保持!