用html+css+js编写一个会动的草莓熊的完整代码
时间: 2023-08-31 22:13:28 浏览: 1496
以下是一个简单的会动的草莓熊的 HTML + CSS + JS 代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>会动的草莓熊</title>
<style>
body {
background-color: #f8f8f8;
}
.bear {
position: absolute;
width: 300px;
height: 300px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
animation: bear 2s infinite;
}
.bear-head {
position: absolute;
width: 180px;
height: 150px;
top: 50px;
left: 60px;
background-color: #f5a9bc;
border-radius: 50% 50% 0 0;
transform: rotate(-20deg);
animation: head 2s infinite;
}
.bear-eyes {
position: absolute;
width: 40px;
height: 40px;
top: 70px;
left: 95px;
background-color: #fff;
border-radius: 50%;
box-shadow: 0 0 5px #000;
animation: eyes 2s infinite;
}
.bear-nose {
position: absolute;
width: 25px;
height: 10px;
top: 90px;
left: 110px;
background-color: #f00;
border-radius: 50%;
transform: rotate(-20deg);
animation: nose 2s infinite;
}
.bear-ears {
position: absolute;
width: 60px;
height: 60px;
top: 10px;
left: 50px;
background-color: #f5a9bc;
border-radius: 50%;
transform: rotate(-40deg);
animation: ears 2s infinite;
}
.bear-mouth {
position: absolute;
width: 80px;
height: 30px;
top: 120px;
left: 75px;
background-color: #f5a9bc;
border-radius: 0 0 50% 50%;
transform: rotate(-20deg);
animation: mouth 2s infinite;
}
.bear-body {
position: absolute;
width: 200px;
height: 200px;
top: 110px;
left: 50px;
background-color: #f5a9bc;
border-radius: 50%;
animation: body 2s infinite;
}
.bear-legs {
position: absolute;
width: 20px;
height: 80px;
top: 200px;
left: 110px;
background-color: #f5a9bc;
border-radius: 10px;
transform: rotate(-20deg);
animation: legs 2s infinite;
}
.bear-arms {
position: absolute;
width: 80px;
height: 20px;
top: 150px;
left: 20px;
background-color: #f5a9bc;
border-radius: 10px;
transform: rotate(20deg);
animation: arms 2s infinite;
}
@keyframes bear {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
50% {
transform: translate(-50%, -50%) rotate(10deg);
}
100% {
transform: translate(-50%, -50%) rotate(0deg);
}
}
@keyframes head {
0% {
transform: rotate(-20deg);
}
50% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-20deg);
}
}
@keyframes eyes {
0% {
top: 70px;
left: 95px;
}
50% {
top: 75px;
left: 100px;
}
100% {
top: 70px;
left: 95px;
}
}
@keyframes nose {
0% {
transform: rotate(-20deg);
}
50% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-20deg);
}
}
@keyframes ears {
0% {
transform: rotate(-40deg);
}
50% {
transform: rotate(-30deg);
}
100% {
transform: rotate(-40deg);
}
}
@keyframes mouth {
0% {
transform: rotate(-20deg);
}
50% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-20deg);
}
}
@keyframes body {
0% {
transform: scale(1);
}
50% {
transform: scale(0.9);
}
100% {
transform: scale(1);
}
}
@keyframes legs {
0% {
transform: rotate(-20deg);
}
50% {
transform: rotate(-10deg);
}
100% {
transform: rotate(-20deg);
}
}
@keyframes arms {
0% {
transform: rotate(20deg);
}
50% {
transform: rotate(10deg);
}
100% {
transform: rotate(20deg);
}
}
</style>
</head>
<body>
<div class="bear">
<div class="bear-head"></div>
<div class="bear-eyes"></div>
<div class="bear-nose"></div>
<div class="bear-ears"></div>
<div class="bear-mouth"></div>
<div class="bear-body"></div>
<div class="bear-legs"></div>
<div class="bear-arms"></div>
</div>
</body>
<script>
alert("点击确定开始观看!");
</script>
</html>
```
草莓熊会在页面中心位置不断摇晃,眼睛、鼻子、耳朵、嘴巴、身体、手臂和腿都会动起来。
阅读全文