6. 作業
作業說明
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<title></title>
<style>
*{
box-sizing: border-box;
}
body{
margin: 0;
}
div.status{
position: fixed;
top: 0;
left: 0;
color: blue;
}
div.ball{
display: inline-block;
width: 100px;
height: 100px;
border-radius: 50%;
position: fixed;
top: 100px;
background: radial-gradient(circle at 25px 25px, hsla(9, 100%, 84%, 1), hsla(9, 100%, 44%, 1));
}
div.ball.-pause{
}
</style>
</head>
<body>
<div class="status"></div>
<div class="ball"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function(){
// 相關事件觸發
$("div.ball").on("animationstart", function(){ // 需有 延遲(animation-delay) 才會觸發
$("div.status").html("動畫:開始");
});
$("div.ball").on("animationiteration", function(){ // 反覆執行時,會觸發
$("div.status").html("動畫:第二次執行(反向)");
});
$("div.ball").on("animationend", function(){ // 動畫效果結束時,會觸發
$("div.status").html("動畫:結束");
});
// 點擊暫停
$("div.ball").on("click", function(){
$(this).toggleClass("-pause");
});
});
</script>
</body>
</html>
參考作法
作業繳交方式
Last updated