CSS3鼠标悬浮环装遮罩效果

快乐打工仔 分类:实例代码

分享一段代码实例,它实现了鼠标悬浮弹出遮罩层效果。

效果是圆形的,并且边框具有旋转功能。

代码实例如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<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>

回复

我来回复
  • 暂无回复内容