HTML关于机器猫的小游戏,完美起航-用HTML5+CSS3画一个简易的机器猫头像

本文介绍如何使用HTML5和CSS3技术绘制机器猫的头像,通过绝对定位、相对定位及浮动布局实现复杂图像。重点展示了背景图像渐变、椭圆边框等技巧的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用HTML5+CSS3画一个机器猫的头像,原图如下:

a457d57e85ed674578b0ac860b69ea5d.png

代码实现效果如下:

ed93487fcb82268609fe479472f5df80.png

布局使用了绝对定位、相对定位以及浮动,鼻子使用了背景图像渐变的效果, 笑脸的嘴巴使用椭圆的下边框实现,胡须部分的细节处理得还是不够好。

代码如下:

CSS样式:

.cat:hover{

transform: scale(1.5);

transition: all 1s;

}

.cat{

position: relative;

z-index: 1;

}

.faceblue {

width: 372px;

height: 372px;

border-radius: 50%;

border: #3f4243 2px solid;

margin: 0 auto;

background-color: #07beea;

position: relative;

}

.facewhite{

width: 250px;

height: 250px;

border: #598680 solid 2px;

border-radius: 50%;

background-color: #fff;

position: absolute;

bottom: 35px;

left: 16%;

/* position: relative; */

}

.eyeleft,.eyeright{

width: 68px;

height: 37px;

border: #3f4243 2px solid;

background-color: #fff;

position: relative;

left: 50px;

top: 6px;

float: left;

}

.eyeright{

left: 60px;

}

.dotleft,.dotright{

background-color: #000;

width: 23px;

height: 23px;

border-radius: 50%;

position: absolute;

left: 28px;

top:6px;

}

.dotright{

left: auto;

right: 28px;

}

.nose{

width: 50px;

height: 50px;

background-image: radial-gradient(#fff 1%,#f00,#f00);

border-radius: 50%;

border: #3f4243 1px solid;

position: absolute;

left: 102px;

top: 50px;

}

.line{

height: 100px;

width: 2px;

background-color: #3f4243;

position: absolute;

left: 127px;

top: 102px;

}

.smile{

width: 163px;

height: 128px;

border: #3f4243 3px solid;

border-radius: 50%;

border-top:none;

border-right:none;

border-left:none;

position: absolute;

left: 44px;

top: 74px;

}

.beard{

position: relative;

top: 75px;

left: 5px;

}

.beard>div{

margin-bottom: 15px;

position: relative;

z-index: 1;

}

.beard1,.beard2,.beard3{

width: 88px;

height: 1px;

background-color: #000;

}

.beard1,.last .beard1{

transform: rotate(16deg);

margin-left: 8px;

width: 80px;

}

.beard3,.last .beard3{

transform: rotate(164deg);

width: 88px;

/* margin-left: 8px; */

}

.last{

position: relative;

top: 22px;

left: -1px;

transform: rotate(180deg);

}

.last .beard3{

width: 80px;

margin-left:8px;

}

.last .beard1{

width: 88px;

margin-left: 2px;

}

HTML结构:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值