代码之家  ›  专栏  ›  技术社区  ›  alonblack

如何获得圆形悬停效果

  •  1
  • alonblack  · 技术社区  · 7 年前

    我怎样才能实现如所附图片(右下图)中那样的圆形悬停效果 circle hover effect

    Here is the fiddle link

    以下是相关css:

    .box_details {
      float:left;
      width:200px;
      height:200px;
      margin-right:35px;
      background-color:#fff;
    
      border-radius:3px;
      box-shadow: 0px 6px 19px 16px rgba(239,242,245,1);
    }
    
    .box_details:hover {
    background-color:#f4f6f8;
    color:#939bc5;
    }
    
    1 回复  |  直到 7 年前
        1
  •  5
  •   Maharkus zok    7 年前

    可以制作一个宽度大于其父元素的圆,并将其居中。请查看代码段以获取这方面的演示。

    .box_details {
      float: left;
      width: 200px;
      height: 200px;
      margin-right: 35px;
      background-color: #fff;
      display: block;
      position: relative;
      border-radius: 3px;
      box-shadow: 0px 6px 19px 16px rgba(239, 242, 245, 1);
      overflow: hidden;
    }
    
    .box_details:hover .circle {
      margin-top: 140px;
      transition-duration: 0.4s;
    }
    
    p {
      text-align: center;
    }
    
    .circle {
      position: absolute;
      width: 200%;
      height: 100px;
      left: 0;
      right: 0;
      margin: 0 auto;
      background: lightgrey;
      border-radius: 50%;
      margin-left: -50%;
      margin-top: 250px;
      transition-duration: 0.4s;
    }
    <div class="box_details">
      <div class="circle">
        <p>Hi!</p>
      </div>
    </div>