返回

无代码魔法:用纯 CSS 打造皮卡丘头像

前端

无需任何编码经验,我们就能用纯 CSS 制作一个皮卡丘头像。我们首先需要创建一个基本的 HTML 结构,然后使用 CSS 来添加样式。

以下是 HTML 代码:

<div class="pikachu">
  <div class="head">
    <div class="left-ear"></div>
    <div class="right-ear"></div>
    <div class="face">
      <div class="eyes"></div>
      <div class="nose"></div>
      <div class="mouth"></div>
    </div>
  </div>
  <div class="body">
    <div class="arms"></div>
    <div class="legs"></div>
    <div class="tail"></div>
  </div>
</div>

现在,让我们使用 CSS 来添加样式。

.pikachu {
  width: 200px;
  height: 200px;
  background-color: #ffeb00;
  border-radius: 50%;
}

.head {
  width: 100px;
  height: 100px;
  background-color: #000;
  border-radius: 50%;
  position: relative;
}

.left-ear {
  width: 25px;
  height: 25px;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  top: -10px;
  left: -10px;
}

.right-ear {
  width: 25px;
  height: 25px;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  top: -10px;
  right: -10px;
}

.face {
  width: 75px;
  height: 75px;
  background-color: #fff;
  border-radius: 50%;
  position: absolute;
  top: 10px;
  left: 10px;
}

.eyes {
  width: 10px;
  height: 10px;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  top: 20px;
  left: 20px;
}

.nose {
  width: 5px;
  height: 5px;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  top: 35px;
  left: 35px;
}

.mouth {
  width: 20px;
  height: 5px;
  background-color: #000;
  border-radius: 5px;
  position: absolute;
  top: 45px;
  left: 25px;
}

.body {
  width: 100px;
  height: 100px;
  background-color: #000;
  border-radius: 50%;
  position: absolute;
  bottom: -50px;
  left: 50px;
}

.arms {
  width: 20px;
  height: 20px;
  background-color: #ffeb00;
  border-radius: 50%;
  position: absolute;
  top: 25px;
  left: -10px;
}

.legs {
  width: 20px;
  height: 20px;
  background-color: #ffeb00;
  border-radius: 50%;
  position: absolute;
  bottom: -10px;
  left: 25px;
}

.tail {
  width: 20px;
  height: 20px;
  background-color: #ffeb00;
  border-radius: 50%;
  position: absolute;
  top: 50px;
  right: -10px;
}

这就是用纯 CSS 制作皮卡丘头像的全部过程。我们只需要简单的 HTML 和 CSS 知识就可以创建一个可爱而复古的头像。