css可以实现很多有趣动画效果,今天我们就用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; filter: blur(3px) contrast(10); } div { position: relative; width: 80px; height: 120px; background: radial-gradient(circle at 60px 40px, #000, #000 7px, transparent 7px), radial-gradient(circle at 40px 40px, #000, #000 7px, transparent 7px), radial-gradient(circle at 50px 50px, #fff, #fff); background-size: 100% 100%; background-repeat: no-repeat; margin: auto; border-radius: 40px 40px 60px 20px; transform: skewX(-10deg); -webkit-animation: moveMain 1.2s infinite ease-out; animation: moveMain 1.2s infinite ease-out; } div::before, div::after { content: ""; position: absolute; background: #fff; border-radius: 50%; } div::before { width: 20px; height: 20px; top: 50px; left: -10px; box-shadow: 0 0 0 1px #fff; -webkit-animation: move 1.2s infinite ease-in; animation: move 1.2s infinite ease-in; } div::after { width: 30px; height: 25px; top: 95px; left: -10px; box-shadow: 0 0 0 1px #fff; -webkit-animation: move2 1.2s infinite ease-in; animation: move2 1.2s infinite ease-in; } @-webkit-keyframes move { 80%, 100% { box-shadow: -60px 0 0 0.5px rgba(255, 255, 255, 0.5); } } @keyframes move { 80%, 100% { box-shadow: -60px 0 0 0.5px rgba(255, 255, 255, 0.5); } } @-webkit-keyframes move2 { 80%, 100% { box-shadow: -100px 0 0 0.5px rgba(255, 255, 255, 0.2); } } @keyframes move2 { 80%, 100% { box-shadow: -100px 0 0 0.5px rgba(255, 255, 255, 0.2); } } @-webkit-keyframes moveMain { 42% { transform: skewX(-10deg) translate(40px, 0); } } @keyframes moveMain { 42% { transform: skewX(-10deg) translate(40px, 0); } } </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> <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)”网站的内容,希望对大家有所帮助!引用本文内容时,请注明出处!谢谢合作!