1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /******************* * 在雪花上奔跑 (逆時針範例,雪花放大至200%,奔跑5秒) * 滑過雪花之後就會自動跑一圈 *******************/ .snowflake, .snowflake:hover { color: #FFFC; opacity: 1; right: 140px; /* 雪花位置 */ bottom: 145px; /* 雪花位置 */ transform: scale(200%); /* 可以放大雪花及奔跑圖,放大200% */ width: 50px; height: 50px; display: flex; justify-content: center; align-items: center; } .snowflake::before { position: absolute; content: ' '; background-image: url('https://emos.plurk.com/f633accedaf53360f817a930c72d6dd8_w22_h23.gif'); /* 奔跑圖片網址 */ background-repeat: no-repeat; background-position: center top; width: calc(100%*1.7); /* 按照圖片大小調整(預設1.7倍) */ height: calc(100%*1.7); /* 按照圖片大小調整(預設1.7倍) */ transform: rotate(-360deg); /* 360deg=順時針跑,-360deg=逆時針跑一圈 */ transition: transform ease-in-out 5s; /* 奔跑時間(預設5秒) */ image-rendering: pixelated; image-rendering: -moz-crisp-edges; image-rendering: crisp-edges; } .snowflake:hover::before { transform: rotate(0deg); transition: ease-in-out 0s; } |
Direct link: https://paste.plurk.com/show/8mVkY4pNGtK8MXFQTSwn