【CSS3】非同步動畫,css3非同步

來源:互聯網
上載者:User

【CSS3】非同步動畫,css3非同步

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>animation-play-state</title><style>#dot,#dot1 {position: absolute;display: inline-block;width: 20px;height: 20px;top:-20px;border-radius: 50%;background-color: #389;-webkit-animation-play-state: paused;}#dot{left:0}#dot1{right:0}#dot.animate {left:300px;-webkit-animation:fadeIn 2s, float 2s 2s infinite;-webkit-animation-play-state: running;/*-webkit-animate: shake 4s 2s both infinite paused;  簡寫在IE10/11中會掛掉*/}#dot1.animate {top:450px;-webkit-animation:fadeInr 1.5s, floatr 3s 1.5s infinite;-webkit-animation-play-state: running;}@-webkit-keyframes fadeIn {0% {opacity: 0; top:0; left:0;}100% {opacity: 1; top:400px; left:300px;}}@-webkit-keyframes float {0% {top: 400px}45% {top: 370px}100% {top: 400px}}@-webkit-keyframes fadeInr {0% {opacity: 0; top:0; right:0;}100% {opacity: 1; top:450px; right:300px;}}@-webkit-keyframes floatr {0% {right: 300px}60% {right: 350px}100% {right: 300px}}</style></head><body><a href="javascript:void(0);" onclick="start();" id="start">start</a><a  href="javascript:void(0);" onclick="stop();" id="stop" style="display:none">stop</a><div id="dot"></div><div id="dot1"></div><script>function start() {var dot = document.getElementById("dot"),dot1 = document.getElementById("dot1"),start = document.getElementById("start"),stop = document.getElementById("stop");start.style.display = "none";stop.style.display = "block";dot.setAttribute("class","animate");dot1.setAttribute("class","animate");}function stop() {var dot = document.getElementById("dot"),dot1 = document.getElementById("dot1"),start = document.getElementById("start"),stop = document.getElementById("stop");start.style.display = "block";stop.style.display = "none";dot.removeAttribute("class");dot1.removeAttribute("class");}</script></body></html>


點擊 start 開始動畫,stop 結束動畫

(PS: 為了節省代碼,唯寫了-webkit-首碼,所以在chrome中測試吧,或者自己加其它首碼 ~。~)


著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.