CSS实现机器人动画

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>像素机器人头像(带眼睛闪烁)</title>
    <style>
        body {
            padding: 100px;
        }

        .robot-avatar {
            font-size: 10px;

            width: 10.4em;
            height: 10em;
            border-radius: 50%;
            background: #ffffff;
            /* 柔和渐变光晕 */
            box-shadow: 0 5px 10px 5px rgba(0, 0, 0, 0.15),
                0 10px 15px 15px rgba(0, 0, 0, 0.1);
            position: relative;
            /* 像素风锯齿边缘 */
            image-rendering: pixelated;
        }

        /* 面部区域 */
        .robot-face {
            width: 6.5em;
            height: 4.5em;
            background: #E65045;
            border-radius: 60% 60% 40% 40%;
            position: absolute;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        /* 眼睛基础样式 + 闪烁动画 */
        .robot-eye {
            width: 0.9em;
            height: 1.8em;
            background: #ffffff;
            border-radius: 0.4em;
            position: absolute;
            top: 33%;
            box-shadow: 0 0 0.5em 0.2em rgba(255, 255, 255, 0.5);
            animation: blink 10s infinite;
            animation-delay: 2s;
        }

        /* 左眼定位 */
        .robot-eye-left {
            left: 25%;
        }

        /* 右眼定位 */
        .robot-eye-right {
            right: 25%;
        }

        /* 耳朵样式 */
        .robot-ear-left {
            width: 1.8em;
            height: 3.5em;
            background: #E65045;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: -0.75em;
            transform: translateY(-50%);
        }

        .robot-ear-right {
            width: 1.8em;
            height: 3.5em;
            background: #E65045;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            right: -0.75em;
            transform: translateY(-50%);
        }

        /* 天线 */
        .robot-antenna {
            display: flex;
            flex-direction: column-reverse;
            align-items: center;
            width: 1.25em;
            height: 2.5em;
            position: absolute;
            z-index: -1;
            top: -2em;
            left: 55%;
            transform: translateX(-10%) rotate(30deg);
            text-align: center;
        }

        .robot-antenna-mast {
            width: 0.5em;
            height: 1.25em;
            background: #ffffff;
            box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1);
        }

        .robot-antenna-ball {
            width: 1.25em;
            height: 1.25em;
            background: #ffffff;
            border-radius: 50%;
            box-shadow: 0 0 20px 10px rgba(0, 0, 0, 0.2);
        }

        /* 关键帧:眼睛闪烁动画 */
        @keyframes blink {

            0% {
                /* 正常状态:白色眼睛 */
                background: #ffffff;
            }

            98% {
                background: #ffffff;
                transform: scaleY(1);
            }

            99% {
                background: #ffffff;
                transform: scaleY(0.1);
            }

            100% {
                background: #ffffff;
                transform: scaleY(1);
            }
        }
    </style>
</head>

<body>
    <div class="robot-avatar">
        <div class="robot-face">
            <div class="robot-eye robot-eye-left"></div>
            <div class="robot-eye robot-eye-right"></div>
        </div>
        <div class="robot-ear-left"></div>
        <div class="robot-ear-right"></div>

        <div class="robot-antenna">
            <div class="robot-antenna-mast"></div>
            <div class="robot-antenna-ball"></div>
        </div>
    </div>
</body>

</html>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容