用html画一个睡觉的熊动画

html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>睡觉的熊动画</title>
  <link rel="stylesheet" href="./style.css">
</head>

<body>
  <div id="container">
    <div class="head"></div>
    <div class="muzzle"></div>
    <div class="ears"></div>
    <div class="body"></div>
    <div class="paws-front"></div>
    <div class="paws-back"></div>
    <div class="details"></div>
    <div class="tail"></div>

    <!-- zzz -->
    <div class="sleep">
      <span class="s1">z</span>
      <span class="s2">z</span>
      <span class="s3">z</span>
      <span class="s4">z</span>
      <span class="s5">z</span>
    </div>
  </div>
</body>

</html>
css 复制代码
body {
  background-color: #EBD8D0;
  text-align: center;
  height: 100%;
  margin: 0px;
}

#container {
  margin: 120px auto;
  position: relative;
  height: 230px;
  width: 754px;
}

#container div {
  position: absolute;
}

#container div::before,
#container div::after {
  content: '';
  position: absolute;
  display: block;
}


/* 头部 */

.head {
  z-index: 10;
  width: 152px;
  height: 70px;
  bottom: 32px;
  left: 143px;
  background: #A78A7F;
  border-radius: 100%;
}

.head:before {
  width: 122px;
  height: 122px;
  left: 54px;
  bottom: 0px;
  z-index: 199;
  background: #594a41;
  border-radius: 90% 50% 90% 90%;
  transform: rotateZ(226deg);
}

.muzzle {
  z-index: 5;
  width: 152px;
  height: 70px;
  bottom: 30px;
  left: 143px;
  background: #A78A7F;
  border-radius: 100%;
}


/* 耳朵 */

.ears {
  width: 42px;
  height: 42px;
  background: #594a41;
  border-radius: 100%;
  left: 220px;
  top: 60px;
  box-shadow: 34px -8px 0 0 #594a41
}


/* 身体 */

.body {
  width: 300px;
  height: 150px;
  background: #594a41;
  left: 228px;
  border-radius: 50%;
  bottom: 29px;
}


/* 前腿 */

.paws-front {
  z-index: 15;
  background: #A78A7F;
  width: 100px;
  height: 50px;
  bottom: 14px;
  left: 272px;
  border-radius: 80% 22% 55% 50% / 55% 22% 80% 50%;
  transform: rotateZ(12deg);
}


/* 后腿 */

.paws-back {
  width: 100px;
  height: 52px;
  border-top-left-radius: 100%;
  background: #A78A7F;
  left: 420px;
  bottom: 29px;
}

.paws-back:after {
  width: 36px;
  height: 52px;
  border-radius: 100%;
  left: 80px;
  background: #A78A7F;
}


/* 鼻子、腮红 */

.details {
  width: 25px;
  height: 25px;
  background: #221E22;
  border-radius: 100%;
  z-index: 20;
  box-shadow: 100px 0 0 #AD5D4E;
  bottom: 66px;
  left: 135px;
}


/* 眼睛 */

.details:after {
  width: 22px;
  height: 22px;
  border-bottom: 5px solid #221E22;
  border-top: 5px solid transparent;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-radius: 50%;
  left: 68px;
  top: -30px;
}


/* 尾巴 */

.tail {
  width: 50px;
  height: 50px;
  background: #594a41;
  border-radius: 100%;
  left: 490px;
  top: 60px;
}


/* 睡觉 zzz */

.sleep {
  height: 90px;
  width: 80px;
  position: absolute;
  left: 80px;
  top: 30px;
  font-size: 55px;
}

.sleep span {
  width: 15px;
  height: 15px;
  display: block;
  font-family: arial;
  font-weight: bold;
  text-align: center;
  line-height: 20px;
  background: #221E22;
  animation: zz 3s linear infinite;
}

.sleep .s1 {
  margin-left: 180px;
  margin-top: -40px;
}

.sleep .s2 {
  margin-left: 120px;
  margin-top: -5px;
}

.sleep .s3 {
  margin-left: 60px;
  margin-top: 5px;
}

.sleep .s4 {
  margin-left: 0px;
  margin-top: 12px;
}

.sleep .s5 {
  margin-left: -5px;
  margin-top: 52px;
}

@keyframes zz {
  0% {
    opacity: 0;
    transform: scale3d(.2, .2, .2) rotate(-20deg);
  }
  50% {
    opacity: 1;
  }
  80% {
    transform: translateY(-30px) translateX(20px) rotate(10deg);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
相关推荐
人工智能训练师1 小时前
Ubuntu22.04如何安装新版本的Node.js和npm
linux·运维·前端·人工智能·ubuntu·npm·node.js
Seveny071 小时前
pnpm相对于npm,yarn的优势
前端·npm·node.js
yddddddy2 小时前
css的基本知识
前端·css
昔人'2 小时前
css `lh`单位
前端·css
破无差3 小时前
《赛事报名系统小程序》
小程序·html·uniapp
Nan_Shu_6144 小时前
Web前端面试题(2)
前端
知识分享小能手4 小时前
React学习教程,从入门到精通,React 组件核心语法知识点详解(类组件体系)(19)
前端·javascript·vue.js·学习·react.js·react·anti-design-vue
蚂蚁RichLab前端团队5 小时前
🚀🚀🚀 RichLab - 花呗前端团队招贤纳士 - 【转岗/内推/社招】
前端·javascript·人工智能
孩子 你要相信光5 小时前
css之一个元素可以同时应用多个动画效果
前端·css
huangql5205 小时前
npm 发布流程——从创建组件到发布到 npm 仓库
前端·npm·node.js