CSS篇--水滴效果(附源码)

效果展示

源码

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Documenttitle>
head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    body{
        display: flex;
        justify-content: center;
        box-sizing: border-box;
        background-color: #2ecc71;
    }
    #water{
        position: relative;
        width: 300px;
        height: 300px;
        margin-top: 100px;
        border-radius: 24% 63% 66% 31% / 53% 38% 61% 45% ;
        box-shadow: inset 10px 10px 20px rgba(0,0,0,0.5),
                          10px 15px 20px rgba(0,0,0,0.4),
                          10px 15px 30px rgba(0,0,0,0.4),
                    inset -10px -10px 15px rgba(253, 253, 253, 0.8);        
        animation: begins 3s linear infinite alternate;
    }
    #water::after{
        content: '';
        position: absolute;
        background-color: rgba(237, 236, 236, 0.952);
        width: 15px;
        height: 15px;
        left: 150px;
        top: 60px;
        border-radius: 43% 54% 63% 32% / 30% 55% 49% 70% ;
    }
    #water::before{
        content: '';
        position: absolute;
        background-color: rgba(236, 235, 235, 0.952);
        width: 20px;
        height: 20px;
        left: 100px;
        top: 50px;
        border-radius: 43% 54% 63% 32% / 30% 55% 49% 70% ;
    }
    @keyframes begins {
        25%{
            border-radius: 40% 59% 75% 34% / 31% 50% 75% 70%  ;
        }
        50%{
            border-radius: 45% 60% 36% 66% / 31% 30% 75% 70%  ;
        }
        100%{
            border-radius: 40% 59% 18% 96% / 31% 50% 75% 70%   ;
        }
    }
style>
<body>
    <div id="water">div>
body>
html>

你可能感兴趣的:(css,css3,前端)