网页绘制皮卡丘代码
时间: 2023-10-29 15:11:20 浏览: 40
以下是使用HTML和CSS绘制皮卡丘的代码:
HTML代码:
```html
<div class="pikachu">
<div class="head">
<div class="ears"></div>
<div class="eyes"></div>
<div class="nose"></div>
<div class="mouth"></div>
</div>
<div class="body"></div>
</div>
```
CSS代码:
```css
/* 设置外框大小和背景颜色 */
.pikachu {
width: 200px;
height: 200px;
background-color: #FFE600;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
position: relative;
overflow: hidden;
}
/* 绘制头部 */
.head {
width: 100px;
height: 100px;
background-color: #FE2C55;
border-radius: 50%;
position: absolute;
top: 30px;
left: 50%;
transform: translateX(-50%);
}
/* 绘制耳朵 */
.ears {
width: 30px;
height: 50px;
background-color: #FE2C55;
border-radius: 50% 50% 0 0;
position: absolute;
top: -20px;
left: 50%;
transform: translateX(-50%);
}
.ears:before,
.ears:after {
content: '';
width: 30px;
height: 30px;
background-color: #FFE600;
border-radius: 50%;
position: absolute;
bottom: 0;
}
.ears:before {
left: -10px;
}
.ears:after {
right: -10px;
}
/* 绘制眼睛 */
.eyes {
width: 60px;
height: 30px;
background-color: #000;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
}
.eyes:before,
.eyes:after {
content: '';
width: 20px;
height: 20px;
background-color: #FFF;
border-radius: 50%;
position: absolute;
top: 5px;
}
.eyes:before {
left: 10px;
}
.eyes:after {
right: 10px;
}
/* 绘制鼻子 */
.nose {
width: 10px;
height: 10px;
background-color: #000;
border-radius: 50%;
position: absolute;
top: 45px;
left: 50%;
transform: translateX(-50%);
}
/* 绘制嘴巴 */
.mouth {
width: 50px;
height: 20px;
border: 2px solid #000;
border-bottom-left-radius: 50px;
border-bottom-right-radius: 50px;
position: absolute;
top: 65px;
left: 50%;
transform: translateX(-50%);
}
/* 绘制身体 */
.body {
width: 200px;
height: 120px;
background-color: #FE2C55;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
```
你可以将以上代码复制到HTML文件中,然后在浏览器中打开HTML文件,就可以看到绘制的皮卡丘了。