CSS3滑鼠懸浮環裝遮罩效果

antzone發表於2018-07-19

分享一段程式碼例項,它實現了滑鼠懸浮彈出遮罩層效果。

效果是圓形的,並且邊框具有旋轉功能。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.demo, .img, .mask, .border {
  width: 300px;
  height: 300px;
  border-radius: 50%;
}
.demo {
  position: relative;
  display: block;
}
.img {
  background-size: cover;
  background-position: 50% 50%;
}
.mask, .border {
  position: absolute;
  top: 0;
  left: 0;
}
.mask {
  text-align: center;
  color: rgba(255,255,255,0);
  transition: all 0.6s ease-in;
}
.info {
  margin-top: 50%;
  transform: translateY(-50%);
}
.border {
  border: 10px solid #10aeff;
  box-sizing: border-box;
  border-top-color: yellow;
  border-left-color: yellow;
  transition: all 0.6s ease-in;
}
.demo:hover .mask {
  background-color: rgba(0,0,0,0.3);
  color: rgba(255,255,255,1);
}
.demo:hover .border {
  transform: rotate(180deg);
}
</style>
</head>
<body>
  <a href="#" class="demo">
    <div class="img"></div>
    <div class="mask">
      <div class="info">
        <h2>螞蟻部落</h2>
        <p>螞蟻部落歡迎您</p>
      </div>
    </div>
    <div class="border"></div>
  </a>
</body>
</html>

相關文章