纯css布局实现一个七星瓢虫效果

代码语言:html

所属分类:布局界面

代码描述:纯css布局实现一个七星瓢虫效果

代码标签: 实现 一个 七星 瓢虫 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
:root {
  --red: #F82222;
  --background-color: #F7B506;
}

body{
  background: var(--background-color);
}

.box-canvas{
  position: relative;
  margin: auto;
  display: block;
  margin-top: 8%;
  margin-bottom: 8%;
  width: 600px;
  height:600px;
}

.body {
  position: absolute;
  left: 50%;
  top: 150px;
  transform: translateX(-50%);
  width: 180px;
  height: 200px;
  background: var(--red);
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--red);
}

/* White dot at top of body */
.body::before {
  content: '';
  position: absolute;
  width: 70px;
  height: 70px;
  background: white;
  border-radius: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Stripe in middle body */
.body::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 200px;
  background: #B21C1C;
  left: 50%;
  transform: translateX(-50%);
}

.spot {
  position: absolute;
  width: 50px;
  height: 50px;
  background: black;
  border-radius: 50%;
  top: 50%;
}

.spot.left {
  left: 25%;
  transform: translate(-25%, -50%);
}

.spot.right {
  right: 25%;
  transform: translate(25%, -50%);
}

/* Top smaller dot */
.spot::before {
  content: '';
  position: absolute;
  width: 25px;
  height: 25px;
  background: black;
  border-radius: 50%;
  top: -35px;
}

.spot.left::before {
  left: -5px;
}

.spot.right::before {
  right: -5px;
}

/* Lower small spots */
.spot::after {
  content: '';
  position: absolute;
  width: 25px;
  height: 25px;
  background: black;
  border-radius: 50%;
  top: 60px;
}

.spot.left::after {
  left: -5px;
}

.spot.right::after {
  right: -5px;
}

.head {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 90px;
  width: 90px;
  height: 90px;
  background: black;
  border-radius: 50% 50% 0 0;
  border: 2px solid black;
  overflow: hidden;
}

/* Left white head spot */
.head::before {
  content: '';
  position: absolute;
  transform: translateX(-50%);
  width: 50px;
  height: 50px;
  background: white;
  border-radius: 50%;
}

/* Right white head spot */
.head::after {
  content: '';
  position: absolute;
  right: 0;
  transform: translateX(50%).........完整代码请登录后点击上方下载按钮下载查看

网友评论0