亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

動(dòng)畫效果--自定義動(dòng)畫

Original 2019-06-01 16:13:40 264
abstract:<!DOCTYPE html><html><head><meta charset="utf-8"> <title>動(dòng)畫效果--自定義動(dòng)畫</title> <meta charset="utf-8">    <script type="tex

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>動(dòng)畫效果--自定義動(dòng)畫</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">  

      // jQuery中我們使用 animate()方法創(chuàng)建自定義的動(dòng)畫


      // 語法:$(selector).animate({params},speed,fn);


      // 必需的 params 參數(shù)定義形成動(dòng)畫的 CSS 屬性。

      // 可選的 speed 參數(shù)規(guī)定效果的時(shí)長(zhǎng)。它可以取以下值:"slow"、"fast" 或毫秒。

      // 可選的 fn是動(dòng)畫完成后所執(zhí)行的函數(shù)

      停止動(dòng)畫:

      stop() 方法用于停止動(dòng)畫或效果,在它們完成之前; 該方法適用于所有 jQuery 效果函數(shù),包括滑動(dòng)、淡入淡出和自定義動(dòng)畫

      語法:

      $(selector).stop(stopAll,goToEnd)      

      可選的參數(shù) stopAll 規(guī)定是否應(yīng)該清除動(dòng)畫隊(duì)列。默認(rèn)是 false 僅停止活動(dòng)的動(dòng)畫,允許任何排入隊(duì)列的動(dòng)畫向后執(zhí)行

      可選的參數(shù) goToEnd 規(guī)定是否立即完成當(dāng)前動(dòng)畫。默認(rèn)是 false

      默認(rèn)情況下 stop() 會(huì)清除在被選元素上指定的當(dāng)前動(dòng)畫

        $(document).ready(function(){

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

            $('p').animate({fontSize:'40px'},1500)//屬性名稱font-size 一律改成駝峰寫法:fontSize

          })  

          //同時(shí)操作多個(gè)css屬性

           //使用預(yù)定義的值 show hide toggle

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

            $('div').animate({

              // left:'400px',//如果想對(duì)元素位置進(jìn)行一個(gè)位移,那么我們需要給當(dāng)前元素設(shè)置一個(gè)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>

<!--  

<button class="but1">點(diǎn)擊字體放大</button>

 <p>jQuery中我們使用 animate()方法創(chuàng)建自定義的動(dòng)畫</p>

 <button class="but2">點(diǎn)擊移動(dòng)div</button>

 <div></div> 

-->

<!-- 點(diǎn)擊右移按鈕,div右移,點(diǎn)擊停止按鈕當(dāng)前效果停止 -->

<button id="right">右移</button>

<button id="stop">停止</button>

<div class="box1"> php中文網(wǎng)</div>

</body>

</html>


Correcting teacher:天蓬老師Correction time:2019-06-03 09:51:49
Teacher's summary:jQuery , 現(xiàn)在可能最引人的地方, 就是他的動(dòng)畫設(shè)計(jì)了. ....

Release Notes

Popular Entries