css实现一个方块猫效果

css实现一个方块猫效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
body{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  margin: -8px;
   background: pink;
}

h1{
  position: relative;
  text-align: center;
  color: #353535;
  margin-bottom: 100px;
}

.box1{
  position: relative;
  width:100px;
  height:70px;
  background:red;
}
.box2{
  position: relative;
  width:200px;
  height:70px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.box3{
  position: relative;
  width:300px;
  height:70px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.cat1{
  position: relative;
  width:100px;
  height:70px;
  background:#000;
  display: inline-block;
}
.cat1:before,.cat1:after{
  content: '';
  position: absolute;
  height: 0px;
  width: 0px;
  border-right: 15px solid transparent;
  border-left: 15px solid transparent;
  border-bottom: 30px solid #000;
  z-index: 2;
}
.cat1:before{
  bottom: 70px;
  left: 5px;
}
.cat1:after{
  bottom: 70px;
  right: 5px;
}
.eye{
  position: relative;
  width:10px;
  height:10px;
  background:#fff;
  border-radius: 100px;
  top: 30px;
  left: 20px;
}
.eye:before{
  content: '';
  position: absolute;
  width:10px;
  height:10px;
  background:#fff;
  border-radius: 100px;
  left: 50px;
}
.mouth{
  position: relative;
  width:8px;
  height:5px;
  background:#fff;
  border-radius: 100px;
  top: 30px;
  left: 46px;
}
.mouth:before, .mouth:after{
  content: '';
  position: absolute;
  width:20px;
  height:20px;
  border-bottom: solid #fff;
  border-radius: 100px;
  bottom: -9px;
}
.mouth:before{
   left: -15px;
}
.mouth:after{
   right: -15px;
}

.cat2{
  position: relative;
  width:100px;
  height:70px;
  background:#fff;
  z-index: 1;
}
.cat2:before, .cat2:after{
  content: '';
  position: absolute;
  height: 0px;
  width: 0px;
  border-right: 15px solid transparent;
  border-left: 15px solid transparent;
  border-bottom: 30px solid #fff;
  z-index: 2;
}
.cat2:before{
  bottom: 70px;
  left: 5px;
}
.cat2:after{
  bottom: 70px;
  right: 5px;
}
.eye2{
  position: relative;
  width:10px;
  height:10px;
  background:#000;
  border-radius: 100px;
  top: 30px;
  left: 20px;
}
.eye2:before{
  content: '';
  position: absolute;
  width:10px;
  height:10px;
  background:#000;
  border-radius: 100px;
  left: 50px;
}
.mouth2{
  position: relative;
  width:8px;
  height:5px;
  background:#000;
  border-radius: 100px;
  top: 30px;
  left: 46px;
}
.mouth2:before, .mouth2:after{
  content: '';
  position: absolute;
  width:20px;
  height:20px;
  border-bottom: solid #000;
  border-radius: 100px;
  bottom: -9px;
}
.mouth2:before{
   left: -15px;
}
.mouth2:after{
   right: -15px;
}
</style>

</head>
<body translate="no">
<h1>Cute Cube Cat</h1>
<div class="box1">
<div class="cat1">
<div class="eye"></div>
<div class="mouth"></div>
</div>
</div>
<div class="box2">
<div class="cat1">
<div class="eye"></div>
<div class="mouth"></div>
</div>
<div class="cat2">
<div class="eye2"></div>
<div class="mouth2"></div>
</div>
</div>
<div class="box3">
<div class="cat2">
<div class="eye2"></div>
<div class="mouth2"></div>
</div>
<div class="cat2">
<div class="eye2"></div>
<div class="mouth2"></div>
</div>
<div class="cat1">
<div class="eye"></div>
<div class="mouth"></div>
</div>
</div>
</div>
</body>
</html>

网友评论0