<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 1. 簡單的fadeIn-fadeOut ![](https://box.kancloud.cn/ef94c2a54f13d2a8f0a38dd69505a494_656x440.gif) ~~~ <style> * { padding: 0; margin: 0; } img { width: 400px; } #parent { margin-left: auto; margin-right: auto; position: relative; width: 400px; border: 1px solid; padding: 20px; border-radius: 3px; } #fade { width: 100%; height: 100%; position: absolute; background: #2dae2d; opacity: 0.3; left: 0; top: 0; z-index: 10; } </style> ~~~ ~~~ <div id="parent"> <img src="images/01.png" alt=""> <div id="fade"></div> </div> <script> //使用定時器 /* 1.執行事件時先清除定時器 2.定時器中的內容,用if-else 來判斷上下限 */ var parent = document.getElementById("parent"); var fade = document.getElementById("fade"); var timer; var opacity = getComputedStyle(fade).opacity * 100; parent.onmouseover = function () { clearTimeout(timer); timer = setInterval(function () { console.log(opacity + 2) if (opacity > 70) { clearTimeout(timer); } else { opacity += 2; fade.style.opacity = opacity / 100; } }, 50) } parent.onmouseout = function () { clearInterval(timer); timer = setInterval(function () { if (opacity < 30) { clearInterval(timer); } else { opacity -= 2; fade.style.opacity = opacity / 100; } }, 50) } </script> ~~~ ## 封裝后的fadeIn-fadeOut ~~~ <script> //使用定時器 /* 1.執行事件時先清除定時器 2.定時器中的內容,用if-else */ var parent = document.getElementById("parent"); var fade = document.getElementById("fade"); var timer; var opacity = getComputedStyle(fade).opacity * 100; /* 1.進入事件后清除定時器 2.在定時器中,loop的代碼和到達臨界值清除定時器的代碼,用if-else分割 */ parent.onmouseover = function () { animate(70,2); } parent.onmouseout = function () { animate(30,-2); } function animate(reach,add){ clearInterval(timer); timer = setInterval(function () { if (opacity == reach) { clearInterval(timer); } else { opacity += add; fade.style.opacity = opacity / 100; } }, 100) } </script> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看