html 与 css 画哆啦A梦

13 篇文章 0 订阅

哆啦A梦

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>哆啦A梦</title>
    <style type="text/css">
        .big {
            width: 500px;
            height: 530px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .head {
            width: 300px;
            height: 300px;
            border-radius: 150px;
            border: 2px solid #333;
            background-image: -webkit-radial-gradient(99% 1%, #fff, #0C99C7 75%, black 100%);
            /* 放射性渐变 */
            background-image: -moz-radial-gradient(99% 1%, #fff, #0C99C7 75%, black 100%);
            background-image: -ms-radial-gradient(99% 1%, #fff, #0C99C7 75%, black 100%);
            box-shadow: -5px 5px 15px 2px #888;
            position: absolute;
            left: 0;
            right: 0;
            margin: auto;
        }

        .face {
            width: 250px;
            height: 210px;
            border-radius: 175px;
            background-color: #fff;
            position: relative;
            left: 25px;
            top: 65px;
        }

        .left_eye {
            width: 60px;
            height: 70px;
            border-radius: 30px;
            border: 2px solid black;
            background-color: #fff;
            position: relative;
            top: -170px;
            left: 87px;
        }

        .left_eyeball {
            width: 12px;
            height: 12px;
            border-radius: 6px;
            background-color: black;
            position: relative;
            top: 10px;
            left: 40px;
            animation-name: cat;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-fill-mode: backwards;
            animation-iteration-count: infinite;
            animation-direction: alternate;
        }

        .right_eye {
            width: 60px;
            height: 70px;
            border-radius: 30px;
            border: 2px solid black;
            background-color: #fff;
            position: relative;
            top: -242px;
            left: 149px;
        }

        .right_eyeball {
            width: 12px;
            height: 12px;
            border-radius: 6px;
            background-color: black;
            position: relative;
            top: 8px;
            left: 10px;
            animation-name: cat;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-fill-mode: backwards;
            animation-iteration-count: infinite;
            animation-direction: alternate;
        }

        @keyframes cat {
            from {
                transform: translate(0, 0);
            }

            20% {
                transform: translate(7px, 7px);
            }

            40% {
                transform: translate(0px, 14px);
            }

            60% {
                transform: translate(7px, 21px);
            }

            80% {
                transform: translate(0px, 28px);
            }

            to {
                transform: translate(7px, 35px);
            }
        }

        .nose {
            width: 28px;
            height: 28px;
            border-radius: 14px;
            border: 2px solid black;
            background-image: -webkit-radial-gradient(10px at 80% 40%, #fff, #cb3a00);
            position: relative;
            top: -254px;
            left: 133px;
        }

        .mouth {
            width: 1px;
            height: 100px;
            border: 1px solid black;
            background-color: black;
            position: relative;
            top: -458px;
            left: 147px;
        }

        .smile {
            width: 200px;
            height: 200px;
            border-radius: 100px;
            border-bottom: 4px solid black;
            position: relative;
            left: 48px;
            top: -354px;
        }

        .gai {
            width: 200px;
            height: 65px;
            background-color: #fff;
            position: relative;
            top: 100px;
        }

        .beard {
            width: 70px;
            height: 1px;
            border: 0.3px solid black;
            background-color: black;
        }

        .lt {
            position: relative;
            top: -555px;
            left: 40px;
            transform: rotate(15deg);
        }

        .lm {
            position: relative;
            top: -535px;
            left: 40px;
        }

        .lb {
            position: relative;
            top: -515px;
            left: 40px;
            transform: rotate(-15deg);
        }

        .gt {
            position: relative;
            top: -564px;
            left: 185px;
            transform: rotate(-15deg);
        }

        .gm {
            position: relative;
            top: -544px;
            left: 185px;
        }

        .gb {
            position: relative;
            top: -524px;
            left: 185px;
            transform: rotate(15deg);
        }

        .body {
            width: 200px;
            height: 200px;
            background-color: #07abdd;
            border: 2px solid #333;
            position: relative;
            top: 290px;
            left: 148px;
            z-index: 10;
        }

        .tummy {
            width: 150px;
            height: 150px;
            border-radius: 75px;
            background-color: #fff;
            border: 2px solid #000;
            position: relative;
            left: 25px;
            top: -10px;
        }

        .pocket {
            width: 120px;
            height: 120px;
            border-radius: 60px;
            background-color: #fff;
            border: 2px solid #000;
            position: relative;
            left: 15px;
            top: 15px;
        }

        .gai_2 {
            width: 124px;
            height: 62px;
            background-color: #fff;
            border-top-left-radius: 50px;
            border-top-right-radius: 50px;
            border-bottom: 2px solid black;
            position: relative;
            left: -2px;
            top: -2px;
        }

        .left_hand {
            width: 70px;
            height: 55px;
            background-color: #07abdd;
            border: 2px solid #333;
            position: relative;
            top: 120px;
            left: 98px;
            transform-origin: 0 50%;
            transform: rotate(-30deg);
            box-shadow: -5px 2px 10px 2px #333;
        }

        .right_hand {
            width: 70px;
            height: 55px;
            background-color: #07abdd;
            border: 2px solid #333;
            position: relative;
            top: 23px;
            left: 336px;
            transform-origin: 0 50%;
            transform: rotate(30deg);
            box-shadow: -5px 2px 10px 2px #333;
        }

        .left_palm {
            width: 70px;
            height: 70px;
            border-radius: 35px;
            border: 2px solid #333;
            background-color: #fff;
            position: relative;
            left: 50px;
            top: 3px;
        }

        .right_palm {
            width: 70px;
            height: 70px;
            border-radius: 35px;
            border: 2px solid #333;
            background-color: #fff;
            position: relative;
            left: 373px;
            top: -73px;
        }

        .rod {
            width: 210px;
            height: 25px;
            border-radius: 100px;
            border: 2px solid #000;
            background-image: linear-gradient(to top, #640C04, #B13206);
            position: relative;
            left: 143px;
            top: -200px;
            z-index: 20;
        }

        .gai_3 {
            width: 5px;
            height: 60px;
            background-color: #07abdd;
            position: relative;
            left: 148px;
            top: -215px;
            z-index: 15
        }

        .gai_4 {
            width: 5px;
            height: 60px;
            background-color: #07abdd;
            position: relative;
            left: 348px;
            top: -275px;
            z-index: 15;
        }

        .dang {
            width: 20px;
            height: 20px;
            border-radius: 10px;
            background-color: #fff;
            border: 2px solid #333;
            position: relative;
            left: 238px;
            top: -140px;
            z-index: 15;
        }

        .dang_gai {
            width: 24px;
            height: 10px;
            background-color: #fff;
            position: relative;
            top: 12px;
            left: -2px;
        }

        .left_foot {
            width: 110px;
            height: 30px;
            border: 2px solid #333;
            border-top-right-radius: 45px;
            border-bottom-right-radius: 45px;
            border-top-left-radius: 65px;
            border-bottom-left-radius: 45px;
            background-color: #fff;
            position: relative;
            left: 130px;
            top: -157px;
            z-index: 15;
            box-shadow: -1px 0px 10px 2px #333;
        }

        .right_foot {
            width: 110px;
            height: 30px;
            border: 2px solid #333;
            border-top-right-radius: 65px;
            border-bottom-right-radius: 45px;
            border-top-left-radius: 45px;
            border-bottom-left-radius: 45px;
            background-color: #fff;
            position: relative;
            left: 255px;
            top: -191px;
            z-index: 15;
            box-shadow: -1px 1px 10px 2px #333;
        }

        .bell {
            width: 36px;
            height: 36px;
            border-radius: 18px;
            background-image: radial-gradient(10px at 75% 25%, #fff, #CDC60B);
            border: 2px solid #000;
            position: relative;
            left: 230px;
            top: -430px;
            z-index: 30;
        }

        .inbell_1 {
            width: 34px;
            height: 3px;
            border: 2px solid #000;
            border-top-left-radius: 3px;
            border-top-right-radius: 4px;
            background-color: none;
            position: relative;
            top: 9px;
            left: -1px;
        }

        .inbell_2 {
            width: 10px;
            height: 10px;
            border-radius: 5px;
            background-color: #000;
            position: relative;
            top: 13px;
            left: 12px;
        }

        .inbell_3 {
            width: 2px;
            height: 10px;
            background-color: #000;
            position: relative;
            left: 16px;
            top: 10px;
        }
    </style>
</head>

<body>
    <div class="big">
        <div class="head">
            <div class="face"></div>
            <div class="left_eye">
                <div class="left_eyeball"></div>
            </div>
            <div class="right_eye">
                <div class="right_eyeball"></div>
            </div>
            <div class="nose"></div>
            <div class="smile">
                <div class="gai"></div>
            </div>
            <div class="mouth"></div>
            <div class="beard lt"></div>
            <div class="beard lm"></div>
            <div class="beard lb"></div>
            <div class="beard gt"></div>
            <div class="beard gm"></div>
            <div class="beard gb"></div>
        </div>


        <div class="body">
            <div class="tummy">
                <div class="pocket">
                    <div class="gai_2">
                    </div>
                </div>
            </div>
        </div>


        <div class="left_hand"></div>
        <div class="right_hand"></div>

        <div class="left_palm"></div>
        <div class="right_palm"></div>

        <div class="rod"></div>


        <div class="gai_3"></div>
        <div class="gai_4"></div>

        <div class="dang">
            <div class="dang_gai"></div>
        </div>

        <div class="left_foot"></div>
        <div class="right_foot"></div>


        <div class="bell">
            <div class="inbell_1"></div>
            <div class="inbell_2"></div>
            <div class="inbell_3"></div>
        </div>

    </div>
</body>
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个HTML+CSS哆啦A梦的示例: 1. 首先,我们需要一个HTML文件,可以使用以下代码: ``` <!DOCTYPE html> <html> <head> <title>哆啦A梦</title> <style> #doraemon { position: relative; width: 200px; height: 200px; background-color: #4d4d4d; border-radius: 100px; overflow: hidden; } #doraemon:before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #fff; border-radius: 100px; transform: translate(30px, 30px); } #doraemon .face { position: absolute; top: 30px; left: 30px; width: 140px; height: 140px; background-color: #fff; border-radius: 70px; overflow: hidden; } #doraemon .face:before { content: ""; position: absolute; top: 5px; left: 5px; width: 130px; height: 130px; background-color: #4d4d4d; border-radius: 65px; } #doraemon .face:after { content: ""; position: absolute; top: 50px; left: 50px; width: 40px; height: 40px; background-color: #fff; border-radius: 20px; } #doraemon .eyes { position: absolute; top: 50px; left: 70px; width: 60px; height: 45px; background-color: #000; border-radius: 30px; overflow: hidden; } #doraemon .eyes:before { content: ""; position: absolute; top: 5px; left: 5px; width: 50px; height: 35px; background-color: #fff; border-radius: 25px; } #doraemon .eyes:after { content: ""; position: absolute; top: 15px; left: 15px; width: 20px; height: 15px; background-color: #000; border-radius: 10px; } #doraemon .mouth { position: absolute; top: 110px; left: 40px; width: 120px; height: 50px; border-radius: 25px; border-top: 2px solid #000; background-color: #fff; transform: rotate(-20deg); } #doraemon .mouth:before { content: ""; position: absolute; top: 5px; left: 5px; width: 110px; height: 40px; background-color: #4d4d4d; border-radius: 20px; transform: rotate(20deg); } #doraemon .whiskers { position: absolute; top: 75px; left: 50px; width: 100px; height: 1px; background-color: #000; transform: rotate(10deg); } #doraemon .whiskers:before { content: ""; position: absolute; top: -5px; left: 0; width: 5px; height: 10px; background-color: #000; transform: rotate(-20deg); } #doraemon .whiskers:after { content: ""; position: absolute; top: 5px; left: 0; width: 5px; height: 10px; background-color: #000; transform: rotate(-20deg); } #doraemon .whiskers:nth-child(2) { transform: rotate(-10deg); } #doraemon .whiskers:nth-child(2):before { transform: rotate(20deg); } #doraemon .whiskers:nth-child(2):after { transform: rotate(20deg); } #doraemon .whiskers:nth-child(3) { transform: rotate(10deg); } #doraemon .whiskers:nth-child(3):before { transform: rotate(-20deg); } #doraemon .whiskers:nth-child(3):after { transform: rotate(-20deg); } </style> </head> <body> <div id="doraemon"> <div class="face"></div> <div class="eyes"></div> <div class="mouth"></div> <div class="whiskers"></div> <div class="whiskers"></div> <div class="whiskers"></div> </div> </body> </html> ``` 2. 接下来,我们来解释一下上面的代码: - 通过`position: relative`设置`#doraemon`为相对定位,以便于后面的绝对定位。 - 设置`width`和`height`为200px,使得`#doraemon`呈现为一个圆形。 - 设置`background-color`为#4d4d4d,使得`#doraemon`呈现为蓝色。 - 通过`border-radius: 100px`将`#doraemon`设置为圆形。 - 通过`overflow: hidden`将`#doraemon`内部的元素裁剪为圆形。 3. 接下来,我们需要用伪元素`::before`来实现哆啦A梦的脸部分: - 通过`content: ""`设置伪元素的内容为空。 - 通过`position: absolute`将伪元素绝对定位在`#doraemon`内部。 - 通过`top`和`left`属性将伪元素相对于`#doraemon`进行定位。 - 通过`width`和`height`设置伪元素的大小。 - 通过`background-color`设置伪元素的颜色。 - 通过`border-radius`将伪元素设置为圆形。 - 通过`transform: translate(30px, 30px)`将伪元素向右下方平移,实现哆啦A梦的脸颊。 4. 接下来,我们需要用`div`元素来实现哆啦A梦的眼睛: - 通过`position: absolute`将眼睛绝对定位在脸部内部。 - 通过`top`和`left`属性将眼睛相对于脸部进行定位。 - 通过`width`和`height`设置眼睛的大小。 - 通过`background-color`设置眼睛的颜色。 - 通过`border-radius`将眼睛设置为半圆形。 - 通过`overflow: hidden`将眼睛内部的元素裁剪为半圆形。 5. 接下来,我们需要用伪元素`::before`来实现哆啦A梦的眼珠: - 通过`content: ""`设置伪元素的内容为空。 - 通过`position: absolute`将伪元素绝对定位在眼睛内部。 - 通过`top`和`left`属性将伪元素相对于眼睛进行定位。 - 通过`width`和`height`设置伪元素的大小。 - 通过`background-color`设置伪元素的颜色。 - 通过`border-radius`将伪元素设置为圆形。 6. 接下来,我们需要用`div`元素来实现哆啦A梦的嘴巴: - 通过`position: absolute`将嘴巴绝对定位在脸部内部。 - 通过`top`和`left`属性将嘴巴相对于脸部进行定位。 - 通过`width`和`height`设置嘴巴的大小。 - 通过`border-radius`将嘴巴设置为半圆形。 - 通过`border-top`设置嘴巴的上边框。 - 通过`background-color`设置嘴巴的颜色。 - 通过`transform: rotate(-20deg)`将嘴巴旋转20度,使得它看起来更加生动。 7. 最后,我们需要用`div`元素和伪元素来实现哆啦A梦的小胡须: - 通过`position: absolute`将小胡须绝对定位在脸部内部。 - 通过`top`和`left`属性将小胡须相对于脸部进行定位。 - 通过`width`和`height`设置小胡须的大小。 - 通过`background-color`设置小胡须的颜色。 - 通过`transform: rotate(10deg)`将小胡须旋转10度,使得它看起来更加生动。 - 通过伪元素来实现小胡须的两端。 到这里,一个HTML+CSS哆啦A梦就完成了。希望这个示例对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值