• 70.纯 CSS 创作一只徘徊的果冻怪兽


    原文地址:https://segmentfault.com/a/1190000015484852

    感想:monster中边框角、上下动画、旋转动画、左右动画,眼睛中transform:scaleY(n);

    HTML code:

    <!-- monster包含其body和eyes -->
    <div class="monster">
        <span class="body"></span>
        <span class="eyes"></span>
    </div>

    CSS code:

    html, body {
        margin: 0;
        padding: 0;
        height: 100vh;
        background-color: black;
    }
    /* 设置前景色 */
    .monster{
        width: 100vw;
        height: 50vh;
        background-color: lightcyan;
    }
    /* 画出monster的body */
    .monster{
        position: relative;
        overflow: hidden;
    }
    .body{
        position: absolute;
        left: -2vmin;
        bottom: calc(-1 * 32vmin / 2 - 4vmin);
        width: 32vmin;
        height: 32vmin;
        border-radius: 43% 40% 43% 40%;
        background-color: teal;
        /* 设置动画 */
        animation:
            bounce 1s infinite alternate,
            wave 3s linear infinite,
            wander 5s linear infinite alternate;
    }
    /* 身体上下跳的动画 */
    @keyframes bounce{
        to{
            bottom: calc(-1 * 32vmin / 2 - 2vmin);
        }
    }
    /* 身体转动的动画 */
    @keyframes wave {
        to {
            transform: rotate(360deg);
        }
    }
    /* monster左右移动*/
    @keyframes wander {
        to {
            left: calc(100% - 32vmin + 2vmin);
        }
    }
    /* monster的eyes容器 */
    .eyes{
        width: 24vmin;
        height: 5vmin;
        position: absolute;
        left: calc(32vmin - 24vmin - 2vmin);
        bottom: 2vmin;
        animation: wander 5s linear infinite alternate;
    }
    /* 用eyes的两个伪元素画出monster的eyes */
    .eyes::before,
    .eyes::after {
        content: '';
        position: absolute;
        box-sizing: border-box;
        width: 5vmin;
        height: 5vmin;
        border: 1.25vmin solid white;
        border-radius: 50%;
        /* 眼睛眨眼 */
        animation: blink 3s infinite linear;
    }
    @keyframes blink {
        4%, 10%, 34%, 40% {
            transform: scaleY(1);
        }
        7%, 37% {
            transform: scaleY(0);
        }
    }
    .eyes::before {
        left: 4vmin;
    }
    .eyes::after {
        right: 4vmin;
    }
  • 相关阅读:
    hdoj Last non-zero Digit in N! 【数论】
    spin_lock &amp; mutex_lock的差别?
    20140514,微软5月14日公布8个安全补丁
    教你用笔记本破解无线路由器password
    SSL工作原理
    MS-SQLSERVER中的MSDTC不可用解决方法
    grub2手动引导ubuntu
    用递归翻转一个栈 Reverse a stack using recursion
    腾讯面试
    AngularJS移动开发中的坑汇总
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10681811.html
Copyright © 2020-2023  润新知