前面几篇文章我们介绍几种使用css实现进度条的方法,今天我们使用css实现一个如下图所示3d水晶进度条效果。
<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实现3d水晶进度条效果www.woaidaogu.com</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> @property --per { syntax: "<percentage>"; inherits: false; initial-value: 0%; } body, html { width: 100%; height: 100%; background: linear-gradient(0deg, #EEEFED, #F9E3E9); display: flex; flex-direction: column; } .perspective { transform-style: preserve-3d; perspective: 520px; transform: rotateX(15deg); } .demo-cube { position: relative; width: 100%; height: 200px; margin: auto; margin-top: -30px; } .demo-cube .cube { display: block; position: absolute; top: 50%; left: 50%; width: 300px; height: 100px; transform-style: preserve-3d; transform-origin: 50px 50px; transform: translate(-50%, -50%) rotateX(-33.5deg); } .demo-cube .cube li { position: absolute; display: block; width: 300px; height: 100px; } .demo-cube .cube .top { transform: rotateX(90deg) translateZ(50px); } .demo-cube .cube .bottom { transform: rotateX(-90deg) translateZ(50px); } .demo-cube .cube .front { transform: translateZ(50px); } .demo-cube .cube .back { transform: rotateX(-180deg) translateZ(50px); } .percentage .cube .top, .percentage .cube .front, .percentage .cube .bottom, .percentage .cube .back { background: linear-gradient(90deg, rgba(156, 39, 176, 0.3), rgba(255, 34, 109, 0.8) 70%, rgba(255, 255, 255, 0.6) 70%, rgba(255, 255, 255, 0.6)); } .colorful { -webkit-animation: hueRotate 10s infinite linear; animation: hueRotate 10s infinite linear; } .colorful .cube .top, .colorful .cube .front, .colorful .cube .bottom, .colorful .cube .back { background: linear-gradient(90deg, rgba(40, 101, 127, 0.9), rgba(133, 165, 181, 0.5) 85%, rgba(255, 255, 255, 0.6) 85%, rgba(255, 255, 255, 0.6)); } .pink .cube .top, .pink .cube .front, .pink .cube .bottom, .pink .cube .back { background: linear-gradient(90deg, rgba(255, 217, 34, 0.6), rgba(255, 34, 109, 0.8) var(--per), rgba(255, 34, 109, 0.1) var(--per), rgba(255, 34, 109, 0.1)); -webkit-animation: perChange 6s infinite; animation: perChange 6s infinite; } @-webkit-keyframes perChange { 0% { --per: 0%; } 90%, to { --per: 80%; } } @keyframes perChange { 0% { --per: 0%; } 90%, to { --per: 80%; } } @-webkit-keyframes hueRotate { 0% { filter: hue-rotate(0); } 100% { filter: hue-rotate(360deg); } } @keyframes hueRotate { 0% { filter: hue-rotate(0); } 100% { filter: hue-rotate(360deg); } } </style> <script> if (document.location.search.match(/type=embed/gi)) { window.parent.postMessage("resize", "*"); } </script> </head> <body translate="no"> <div class="demo-cube perspective percentage"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="demo-cube perspective colorful"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="demo-cube perspective pink"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <script src="https://cpwebassets.codepen.io/assets/editor/iframe/iframeRefreshCSS-4793b73c6332f7f14a9b6bba5d5e62748e9d1bd0b5c52d7af6376f3d1c625d7e.js"></script> <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如何实现3d水晶进度条效果?感谢您访问“我爱捣鼓(www.woaidaogu.com)”网站的内容,希望对大家有所帮助!引用本文内容时,请注明出处!谢谢合作!