使用过华为手机的朋友都知道当给手机充上电时,屏幕上的充电动画效果非常酷炫,今天我们就用css来实现这样的效果。
<html><head> <meta charset="UTF-8"> <link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png"> <meta name="apple-mobile-web-app-title" content="CodePen"> <link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico"> <link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-8f3771b1072e3c38bd662872f6b673a722f4b3ca2421637d5596661b4e2132cc.svg" color="#111"> <title>css实现华为充电酷炫动画效果www.woaidaogu.com</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> html, body { width: 100%; height: 100%; display: flex; background: #000; overflow: hidden; } .g-number { position: absolute; width: 300px; top: 27%; text-align: center; font-size: 32px; z-index: 10; color: #fff; } .g-container { position: relative; width: 300px; height: 400px; margin: auto; } .g-contrast { filter: contrast(10) hue-rotate(0); width: 300px; height: 400px; background-color: #000; overflow: hidden; -webkit-animation: hueRotate 10s infinite linear; animation: hueRotate 10s infinite linear; } .g-circle { position: relative; width: 300px; height: 300px; box-sizing: border-box; filter: blur(8px); } .g-circle::after { content: ""; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(0); width: 200px; height: 200px; background-color: #00ff6f; border-radius: 42% 38% 62% 49%/45%; -webkit-animation: rotate 10s infinite linear; animation: rotate 10s infinite linear; } .g-circle::before { content: ""; position: absolute; width: 176px; height: 176px; top: 40%; left: 50%; transform: translate(-50%, -50%); border-radius: 50%; background-color: #000; z-index: 10; } .g-bubbles { position: absolute; left: 50%; bottom: 0; width: 100px; height: 40px; transform: translate(-50%, 0); border-radius: 100px 100px 0 0; background-color: #00ff6f; filter: blur(5px); } li { position: absolute; border-radius: 50%; background: #00ff6f; } li:nth-child(0) { left: 41px; top: 50%; transform: translate(-50%, -50%); width: 25px; height: 25px; -webkit-animation: moveToTop 7s ease-in-out -2.078s infinite; animation: moveToTop 7s ease-in-out -2.078s infinite; } li:nth-child(1) { left: 73px; top: 50%; transform: translate(-50%, -50%); width: 27px; height: 27px; -webkit-animation: moveToTop 4s ease-in-out -2.749s infinite; animation: moveToTop 4s ease-in-out -2.749s infinite; } li:nth-child(2) { left: 30px; top: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; -webkit-animation: moveToTop 7s ease-in-out -3.531s infinite; animation: moveToTop 7s ease-in-out -3.531s infinite; } li:nth-child(3) { left: 25px; top: 50%; transform: translate(-50%, -50%); width: 28px; height: 28px; -webkit-animation: moveToTop 5s ease-in-out -2.831s infinite; animation: moveToTop 5s ease-in-out -2.831s infinite; } li:nth-child(4) { left: 30px; top: 50%; transform: translate(-50%, -50%); width: 26px; height: 26px; -webkit-animation: moveToTop 4s ease-in-out -4.635s infinite; animation: moveToTop 4s ease-in-out -4.635s infinite; } li:nth-child(5) { left: 28px; top: 50%; transform: translate(-50%, -50%); width: 19px; height: 19px; -webkit-animation: moveToTop 8s ease-in-out -4.057s infinite; animation: moveToTop 8s ease-in-out -4.057s infinite; } li:nth-child(6) { left: 20px; top: 50%; transform: translate(-50%, -50%); width: 19px; height: 19px; -webkit-animation: moveToTop 6s ease-in-out -2.653s infinite; animation: moveToTop 6s ease-in-out -2.653s infinite; } li:nth-child(7) { left: 80px; top: 50%; transform: translate(-50%, -50%); width: 23px; height: 23px; -webkit-animation: moveToTop 5s ease-in-out -1.79s infinite; animation: moveToTop 5s ease-in-out -1.79s infinite; } li:nth-child(8) { left: 76px; top: 50%; transform: translate(-50%, -50%); width: 26px; height: 26px; -webkit-animation: moveToTop 7s ease-in-out -0.813s infinite; animation: moveToTop 7s ease-in-out -0.813s infinite; } li:nth-child(9) { left: 37px; top: 50%; transform: translate(-50%, -50%); width: 27px; height: 27px; -webkit-animation: moveToTop 7s ease-in-out -2.532s infinite; animation: moveToTop 7s ease-in-out -2.532s infinite; } li:nth-child(10) { left: 24px; top: 50%; transform: translate(-50%, -50%); width: 20px; height: 20px; -webkit-animation: moveToTop 7s ease-in-out -4.09s infinite; animation: moveToTop 7s ease-in-out -4.09s infinite; } li:nth-child(11) { left: 54px; top: 50%; transform: translate(-50%, -50%); width: 20px; height: 20px; -webkit-animation: moveToTop 9s ease-in-out -3.521s infinite; animation: moveToTop 9s ease-in-out -3.521s infinite; } li:nth-child(12) { left: 81px; top: 50%; transform: translate(-50%, -50%); width: 25px; height: 25px; -webkit-animation: moveToTop 6s ease-in-out -4.091s infinite; animation: moveToTop 6s ease-in-out -4.091s infinite; } li:nth-child(13) { left: 82px; top: 50%; transform: translate(-50%, -50%); width: 19px; height: 19px; -webkit-animation: moveToTop 4s ease-in-out -1.001s infinite; animation: moveToTop 4s ease-in-out -1.001s infinite; } li:nth-child(14) { left: 72px; top: 50%; transform: translate(-50%, -50%); width: 20px; height: 20px; -webkit-animation: moveToTop 4s ease-in-out -4.67s infinite; animation: moveToTop 4s ease-in-out -4.67s infinite; } li:nth-child(15) { left: 79px; top: 50%; transform: translate(-50%, -50%); width: 26px; height: 26px; -webkit-animation: moveToTop 7s ease-in-out -1.167s infinite; animation: moveToTop 7s ease-in-out -1.167s infinite; } @-webkit-keyframes rotate { 50% { border-radius: 45%/42% 38% 58% 49%; } 100% { transform: translate(-50%, -50%) rotate(720deg); } } @keyframes rotate { 50% { border-radius: 45%/42% 38% 58% 49%; } 100% { transform: translate(-50%, -50%) rotate(720deg); } } @-webkit-keyframes moveToTop { 90% { opacity: 1; } 100% { opacity: 0.1; transform: translate(-50%, -180px); } } @keyframes moveToTop { 90% { opacity: 1; } 100% { opacity: 0.1; transform: translate(-50%, -180px); } } @-webkit-keyframes hueRotate { 100% { filter: contrast(15) hue-rotate(360deg); } } @keyframes hueRotate { 100% { filter: contrast(15) hue-rotate(360deg); } } </style> <script> window.console = window.console || function(t) {}; </script> <script> if (document.location.search.match(/type=embed/gi)) { window.parent.postMessage("resize", "*"); } </script> </head> <body translate="no"> <div> <div>98.7%</div> <div> <div></div> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> </div> <div id="xl_chrome_ext_{4DB361DE-01F7-4376-B494-639E489D19ED}" style="display: none;"> <div></div> <a id="xl_chrome_ext_download" href="javascript:;">下载视频</a> <a id="xl_chrome_ext_close" href="javascript:;"></a> </div></body></html>
通过以上内容我们知道了css如何实现华为充电酷炫的动画效果?感谢您访问“我爱捣鼓(www.woaidaogu.com)”网站的内容,希望对大家有所帮助!引用本文内容时,请注明出处!谢谢合作!