html制作卡通图案代码,使用HTML和CSS3绘制基本卡通图案的示例分享
时间: 2023-06-24 08:04:15 浏览: 131
HTML5+CSS3实现好看的卡通动画特效源码.zip
以下是一个简单的使用HTML和CSS3绘制基本卡通图案的示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>卡通图案</title>
<style>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.circle {
width: 200px;
height: 200px;
background-color: #ffbb00;
border-radius: 50%;
position: relative;
overflow: hidden;
transform: rotate(-45deg);
}
.circle:before {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 150px;
height: 150px;
background-color: #fff;
border-radius: 50%;
}
.circle:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
background-color: #ffbb00;
border-radius: 50%;
z-index: 1;
}
.eyes {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50px;
height: 50px;
background-color: #fff;
border-radius: 50%;
z-index: 2;
}
.eye {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
background-color: #000;
border-radius: 50%;
}
.eye.left {
transform: translate(-50%, -50%) translateX(-30px);
}
.eye.right {
transform: translate(-50%, -50%) translateX(30px);
}
.mouth {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80px;
height: 40px;
background-color: #fff;
border-radius: 50px/20px;
border-top: 5px solid #000;
z-index: 2;
}
.tongue {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 40px;
height: 20px;
background-color: #ff4444;
border-radius: 50px/10px;
border-top: 3px solid #fff;
z-index: 3;
}
</style>
</head>
<body>
<div class="container">
<div class="circle">
<div class="eyes">
<div class="eye left"></div>
<div class="eye right"></div>
</div>
<div class="mouth"></div>
<div class="tongue"></div>
</div>
</div>
</body>
</html>
```
这个示例中,我们使用了CSS3的一些特性,如圆角、旋转和伪元素等,来绘制一个简单的卡通图案。你可以将其复制并粘贴到一个HTML文件中,然后在浏览器中打开它,就可以看到卡通图案了。
阅读全文