css3實現邊框具有動態環形遮罩效果

antzone發表於2017-03-24

分享一段程式碼例項,它實現了邊框動態環形遮罩效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
* {
  padding: 0;
  margin: 0;
}
.circle-wrap {
  position: relative;
  float: left;
  margin-left: 20px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  box-sizing: border-box;
  overflow: hidden;
}
.circle-wrap .circle-shut {
  width: 210px;
  height: 210px;
  border: 10px solid #000;
  border-right-color: red;
  border-bottom-color: red;
  border-radius: 50%;
  box-sizing: border-box;
  transition: all .8s ease-in-out;
}
.circle-wrap .circle-img {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 190px;
  height: 190px;
  z-index: -1;
  border-radius: 50%;
  box-sizing: border-box;
}
.circle-wrap .circle-img img {
  max-width: 100%;
}
.circle-wrap .circle-details {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 190px;
  height: 190px;
  z-index: 2;
  box-sizing: border-box;
  background-color: #000;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  border-radius: 50%;
}
.circle-wrap .circle-details-main {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  text-align: center;
  line-height: 200px;
  color: #fff;
  font-weight: 700;
  opacity: 0;
  transition: opacity 1s ease-in-out;
}
.circle-wrap:hover .circle-shut {
  transform: rotate(90deg);
}
.circle-wrap:hover .circle-details {
  opacity: .5;
}
.circle-wrap:hover .circle-details-main {
  opacity: 1;
}
</style>
</head>
<body>
  <div class="circle-wrap">
    <div class="circle-shut"></div>
    <div class="circle-details"></div>
    <div class="circle-details-main">螞蟻部落一</div>
  </div>
  <div class="circle-wrap">
    <div class="circle-shut"></div>
    <div class="circle-details"></div>
    <div class="circle-details-main">螞蟻部落二</div>
  </div>
  <div class="circle-wrap">
    <div class="circle-shut"></div>
 
    <div class="circle-details"></div>
    <div class="circle-details-main">螞蟻部落三</div>
  </div>
</body>
</html>

相關文章