html写一个动漫效果
时间: 2023-07-07 19:38:42 浏览: 47
以下是一个简单的动漫效果的HTML和CSS代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>动漫效果</title>
<style>
.container {
position: relative;
width: 500px;
height: 400px;
margin: 0 auto;
background-color: #f6f6f6;
}
.box {
position: absolute;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
background-color: #ff5722;
border-radius: 50%;
animation: anime 2s ease-in-out infinite alternate;
}
@keyframes anime {
from {
transform: translate(-50%, -50%) scale(1);
}
to {
transform: translate(-50%, -50%) scale(1.2);
}
}
</style>
</head>
<body>
<div class="container">
<div class="box"></div>
</div>
</body>
</html>
```
此代码创建了一个包含一个圆形盒子的容器,圆形盒子使用CSS的`animation`属性实现动漫效果。通过设置`animation`属性的值,可以定义动画的名称、持续时间、缓动函数和循环方式。在本例中,动画名称为`anime`,持续时间为2秒,缓动函数为`ease-in-out`,循环方式为`infinite alternate`。`@keyframes`规则定义了动画的两个关键帧,分别是`from`和`to`,并设置了每个关键帧的CSS属性值。在本例中,动画将圆形盒子从原始大小不断放大和缩小。