<div class="levels">
    <div class="level one">
      <div class="title">One</div>
      <div class="content">One Content</div>
    </div>
    <div class="level two">
      <div class="title">Two</div>
      <div class="content">Two Content</div>
    </div>
    <div class="level three">
      <div class="title">Three</div>
      <div class="content">Three Content</div>
    </div>
    <div class="level four">
      <div class="title">Four</div>
      <div class="content">Four Content</div>
    </div>
  </div>

:root {
  --fontColor: #ffc0cb;
  --one1: #bd7be8;
  --one2: #8063e1;
  --two1: #7f94fc;
  --two2: #3f58e3;
  --three1: #21bbfe;
  --three2: #2c6fd1;
  --four1: #415197;
  --four2: #352f64;
  --levelShadow: #22325480;
  --itemWidth:280px;
  --itemHeight:140px;
}

.levels {
/*   居中 */
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -140px;
  margin-top: -90px;
/*   维持3D场景 */
  transform-style: preserve-3d;
/*   取消文字选择 */
  user-select: none;
}
.levels .level {
  width: var(--itemWidth);
  height: var(--itemHeight);
  border-radius: 12px;
  color: var(--fontColor);
  cursor: pointer;
  

  transition: all 0.4s ease;
  /*   卡片旋转 */
  transform: rotateX(45deg) rotateY(-15deg) rotate(45deg);
  opacity: 0.9;
/*   margin-top: -70px; */
  margin-top: 0px;
}


.levels .level.one {
  background: linear-gradient(135deg, var(--one1), var(--one2));
/*   第一个是向下投影,第二个是边框阴影 */
  box-shadow: 20px 20px 60px var(--levelShadow), 1px 1px 0px 1px var(--one2);
  z-index: 4;
}
.levels .level.two {
  background: linear-gradient(135deg, var(--two1), var(--two2));
  box-shadow: 20px 20px 60px var(--levelShadow), 1px 1px 0px 1px var(--two2);
  z-index: 3;
}
.levels .level.three {
  background-image: linear-gradient(135deg, var(--three1), var(--three2));
  box-shadow: 20px 20px 60px var(--levelShadow), 1px 1px 0px 1px var(--three2);
  z-index: 2;
}
.levels .level.four {
  background-image: linear-gradient(135deg, var(--four1), var(--four2));
  box-shadow: 20px 20px 60px var(--levelShadow), 1px 1px 0px 1px var(--four2);
  z-index: 1;
}




.levels .level .title {
  position: absolute;
  top: 28px;
  left: 15px;
  font-size: 26px;
  font-weight: bold;
}
.levels .level .content {
  position: absolute;
  font-weight: 700;
  bottom: 15px;
  left: 15px;
  font-size: 16px;
}

/* 鼠标悬停,改变 */
.levels .level:hover {
  transform: rotateX(30deg) rotateY(-15deg) rotate(30deg) translate(-25px, 50px);
  opacity: 0.6;
}


/* 颜色流动 */
.levels .level:hover:after {
  transform: translateX(100%);
  transition: all 1.2s ease-in-out;
}


/* 设置平行一个矩形,会在卡片上移动,为了产生颜色流动设计了一个白色渐变 */
.levels .level::after {
  content: '';
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateX(-100%);
  background: linear-gradient(60deg, rgba(255,255,255,0) 20%, rgba(255,255,255,0.1), rgba(255,255,255,0) 80%);
}



// css——stylus格式

// level($bgColor, $startColor, $endColor, $boxColor, $z-index) {
//   margin-top:-70;
//   background-image:$bgColor;
//   background-image: linear-gradient(135deg, $startColor, $endColor);
//   box-shadow: 20px 20px 60px var(--levelShadow), 1px 1px 0px 1px $boxColor;
//   z-index: $z-index;
// }
// .levels .level.one {
//   level(#8063e1,var(--one1), var(--one2), var(--one2),4);
// }

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.