如何用手机HTML制作哆啦a梦,CSS3绘制哆啦A梦(带鼠标动画)

body{

margin: 0;

background: lightblue;

}

/*哆啦A梦*/

.doa{

position: relative;

top: 100px;

}

.head{

margin: 0 auto;

width: 400px;

height: 350px;

background: #008ee3;

position: relative;

border-radius: 50% 50% 25% 25% / 55% 55% 45% 45%;

}

.head:hover .face>div:first-child div{

left: 0px;

transition: all 1s;

}

.head:hover .face>div:first-child div div{

left: 0px;

transition: all 1s;

}

.head:hover{

}

.face{

width: 310px;

height: 260px;

background: snow;

border-radius: 50% 50% 25% 25% / 55% 55% 45% 45%;

position: relative;

top: 90px;

left: 45px;

}

/*左眼眶*/

.face>div:first-child{

width: 80px;

height: 100px;

border-radius: 50%;

border:2px #000 solid;

background: snow;

float: left;

position: relative;

top:-40px;

left: 71px;

z-index: 50;

}

/*右眼眶*/

.face>div:last-child{

width: 80px;

height: 100px;

border-radius: 50%;

border:2px #000 solid;

background: snow;

float: left;

position: relative;

top:-40px;

left: 71px;

z-index: 50;

}

/*左眼珠1*/

.face>div:first-child div{

width: 20px;

height: 25px;

background: #000;

border-radius: 50%;

position: absolute;

top: 45px;

left: 60px;

}

/*左瞳孔*/

.face>div:first-child div div{

width: 10px;

height: 10px;

background: #ffffff;

border-radius: 50%;

position: absolute;

top: 7px;

left: 10px;

}

/*右眼珠*/

.face>div:last-child div{

width: 20px;

height: 25px;

background: #000;

border-radius: 50%;

position: absolute;

top: 45px;

}

/*右瞳孔*/

.face>div:last-child div div{

width: 10px;

height: 10px;

background: #ffffff;

border-radius: 50%;

position: absolute;

top: 7px;

}

.nose{

width: 30px;

height: 30px;

border-radius: 50%;

background: #c70000;

position: absolute;

top: 130px;

left: 50%;

margin-left: -15px;

z-index: 10;

}

.nose div{

width: 10px;

height: 10px;

border-radius: 50%;

position: absolute;

background: #ffffff;

top: 10px;

margin-left: 20px;

z-index: 10;

}

.nose1{

width: 2px;

height: 130px;

background: #000;

position: absolute;

top: 160px;

left: 50%;

margin-left: -1px;

z-index: 10;

}

.mouth{

width: 250px;

height: 200px;

border-radius: 50%;

background: snow;

border-bottom: 2px #000 solid;

margin: -230px auto;

position: relative;

}

.mouth div:first-child{

width: 82px;

height: 2px;

background: #000;

position: absolute;

z-index: 1000;

top: -25px;

left: 6px;

display: none;

}

.mouth div:nth-child(2){

width: 82px;

height: 2px;

background: #000;

position: absolute;

z-index: 1000;

top: -25px;

left: 90px;

display: none;

}

.mouth:hover{

border-radius: 0;

width: 180px;

height: 200px;

}

.mouth:hover div:first-child,.mouth:hover div:nth-child(2){

display: block;

}

.neck{

width: 330px;

height: 200px;

border-radius: 50% 50% 20% 20% / 50% 50% 50% 50%;

background: #e30000;

margin: 80px auto;

z-index: 100;

}

.neck div:first-child{

border: 2px #000 solid;

border-radius: 50%;

width: 40px;

height: 40px;

background: #ffdd2e;

position: absolute;

top: 350px;

left: 50%;

margin-left: -22px;

transition: all 1s;

}

.neck div:nth-child(2){

border: 2px #000 solid;

width: 44px;

height: 5px;

background: #ffdd2e;

position: absolute;

left: 50%;

margin-left: -24px;

top: 363px;

border-radius: 5px;

transition: all 1s;

}

.neck div:nth-child(3){

width: 8px;

height: 8px;

border: 2px #000 solid;

position: absolute;

background: #6c5844;

border-radius: 50%;

left: 50%;

margin-left: -6px;

top: 375px;

transition: all 1s;

}

.neck div:nth-child(4){

width: 2px;

height: 8px;

background: #000;

position: absolute;

left: 50%;

margin-left: -1px;

top: 385px;

transition: all 1s;

}

.neck:hover div:first-child{

width: 60px;

height: 60px;

left: 50%;

margin-left: -30px;

}

.neck:hover div:nth-child(2){

width: 66px;

height: 7.5px;

left: 50%;

margin-left: -33px;

}

.neck:hover div:nth-child(3){

width: 12px;

height: 12px;

left: 50%;

margin-left: -6px;

top: 385px;

}

.neck:hover div:nth-child(4){

width: 2px;

height: 12px;

left: 50%;

margin-left: 1px;

top: 400px;

}

.beard .left div:first-child{

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 10% 90% 10% 90% / 10% 90% 10% 90%;

position: absolute;

left: 50%;

top: 140px;

margin-left: -170px;

z-index: 100;

}

.beard .left div:nth-child(2){

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 10% 90% 10% 90% / 30% 70% 40% 60%;

position: absolute;

left: 50%;

top: 170px;

margin-left: -170px;

z-index: 100;

}

.beard .left div:last-child{

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 10% 90% 10% 90% / 40% 60% 10% 90%;

position: absolute;

left: 50%;

top: 200px;

margin-left: -170px;

z-index: 100;

}

.beard .right div:first-child{

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 90% 10% 90% 10% / 90% 10% 90% 10%;

position: absolute;

left: 50%;

top: 140px;

margin-left: 50px;

z-index: 100;

}

.beard .right div:nth-child(2){

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 90% 10% 90% 10% / 70% 30% 60% 40%;

position: absolute;

left: 50%;

top: 170px;

margin-left: 50px;

z-index: 100;

}

.beard .right div:last-child{

width: 120px;

height: 40px;

border-top: 2px #000 solid;

border-radius: 90% 10% 90% 10% / 60% 40% 90% 10%;

position: absolute;

left: 50%;

top: 200px;

margin-left: 50px;

z-index: 100;

}

.beard span{

display: block;

width: 60px;

height: 3.5px;

background: #ffffff;

border-radius: 4px;

position: absolute;

top: 352px;

left: 50%;

margin-left: -105px;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值