CSS3 transition 小米商品上浮动画

552 阅读1分钟
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      background-color: #eee;
    }
    .items {
      width: 1300px;
      margin: 100px auto;
    }
    .item {
      float: left;
      width: 234px;
      height: 300px;
      background-color: #fff;
      margin-right: 20px;
      text-align: center;
      position: relative;
      overflow: hidden;

      transition: all 0.3s ;
    }
    .item span {
      position: absolute;
      width: 100%;
      height: 80px;
      background-color: #0f4;
      left: 0;
      bottom: -80px;
      /* 过渡动画 */
      transition: all 0.5s;
    }
    .item:hover span {
      bottom: 0;
    }
    .item:hover {
      box-shadow: 0 0 20px 2px #ccc;
      margin-top: -3px;
    }
  </style>
</head>
<body>
  <div class="items">
    <div class="item">
      <img src="xiaomi1.jpg" alt="">
    </div>
    <div class="item">
      <img src="xiaomi2.jpg" alt="">
      <span></span>
    </div>
    <div class="item">
      <img src="xiaomi3.jpg" alt="">
      <span></span>
    </div>
    <div class="item">
      <img src="xiaomi4.jpg" alt="">
      <span></span>
    </div>
    <div class="item">
      <img src="xiaomi5.jpg" alt="">
      <span></span>
    </div>
  </div>
</body>
</html>

  • 效果图