用Github五萬顆星的css動畫庫, 為網頁增添趣味性

css動畫可以做到什麼程度?
Github上有一個非常優秀的動畫專案, 足足有5萬顆星!
線上效果展示:

animate整個專案只有一個css檔案, 使用方法也非常簡單, 只要給相應的元素新增class屬性即可
通過懸浮產生動畫的小Demo

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="./animate.css"> <title>Animate的動畫展示</title> </head> <body> <style> body, html{ margin: 0; padding: 0; } #title{ margin-top: 200px; font-size: 30px; line-height: 60px; font-size: 0; width: 100%; font-weight: bold; color: #AB3319; } #title span{ font-size: 20px; background-color: #FCF6E5; display: inline-block; width: 20%; height: 60px; text-align: center; box-sizing: border-box; border: 1px solid #A84631; } </style> <div class="animated infinite flip delay-2s" style="text-align: center; font-size: 60px; margin-top: 30px; color: #64B587;"> Animate動畫展示</div> <div id="title"> <span>推薦</span> <span>排行榜</span> <span>歌單</span> <span>電臺</span> <span>歌手</span> </div> <script> const spans = window.document.querySelector("#title").querySelectorAll("span"); for(let span_index = 0; span_index < spans.length; span_index++){ spans[span_index].addEventListener("mouseenter", (e)=>{ console.log(spans[span_index], "enter"); spans[span_index].setAttribute("class", 'animated rubberBand'); }) spans[span_index].addEventListener("mouseleave", (e)=>{ console.log(spans[span_index], "mouseleave") spans[span_index].setAttribute("class", ''); }) } </script> </body> </html>
小結:
為網站新增css動畫, 是為網頁增加趣味性最簡單的方法~