纯css代码制作水滴效果

发表在    IT女(Java部落) 12-08 18:43:11

1 5089 0

新建一个文件,把后缀改为.html,复制粘贴下面的代码,打开就能看到效果了


<html lang="en">
<head>
<!--网站编码格式,UTF-8 国际编码,GBKgb2312 中文编码-->
<meta charset="UTF-8">
<meta name="Keywords" content="css代码"><meta name="Description" content="css代码">
<title>纯css代码制作水滴效果</title>
<style> html, body { margin: 0; height: 100%; width: 100%; display: flex; background-color: #43A2CE; } .drip { width: 200px; height: 250px; display: flex; flex-wrap: wrap; justify-content: center; margin: auto; position: relative; } .drip:before { position: absolute; left: 92.5px; top: 0; content: ''; width: 15px; height: 15px; background-color: #FFF; border-radius: 50%; opacity: 0; animation: drip 4s ease infinite; } .drip:after { box-sizing: border-box; position: absolute; bottom: 0; left: 0; content: ''; width: 0px; height: 0px; border: solid 4px #FFF; border-radius: 50%; opacity: 0; animation: splash 4s ease infinite; } @keyframes drip { 10% { top: 0; opacity: 1; animation-timing-function: cubic-bezier(0.24, 0, 0.76, 0.14); } 25% { opacity: 1; top: 200px; animation-timing-function: ease-out; width: 15px; height: 15px; left: 92.5px; } 30% { opacity: 1; top: 160px; width: 5px; height: 5px; animation-timing-function: ease-in; left: 97.5px; } 33% { top: 200px; opacity: 0; animation-timing-function: ease-out; left: 97.5px; } 33.001% { opacity: 0; } 100% { opacity: 0; } } @keyframes splash { 0% { opacity: 0; } 25% { bottom: 50px; left: 100px; opacity: 0; width: 0px; height: 0px; } 25.001% { opacity: 1; } 33% { bottom: 0; left: 0; opacity: 0; width: 200px; height: 100px; } 33.001% { bottom: 50px; left: 100px; opacity: 1; width: 0px; height: 0px; } 43% { bottom: 0; left: 0; opacity: 0; width: 200px; height: 100px; } 43.001% { opacity: 0; } } </style> </head> <body> <div class="drip"></div> </body> </html>


登录或注册后发布评论