滑鼠懸浮可以實現圓角矩形明亮變化效果

antzone發表於2017-03-02

分享一段程式碼例項,它實現了滑鼠懸浮實現矩形明亮變化效果。

矩形具有圓角效果,程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.pesudo{
  position: absolute;
  top:50%;
  left: 50%;
  transform:translate(-50%,-50%);
  width: 120px;
  padding: 60px;
  text-align: center;
  color: white;
  font-size: 200%;
  border-radius:1em;
  background:#00aabb;
  cursor:pointer;
}
.pesudo:before{
  position: absolute;
  top: 0; 
  right: 0; 
  bottom: 0; 
  left: 0;
  z-index:-1;
  border-radius:1em;
  background:rgba(0,0,0,.1);
}
.pesudo:hover:before{
  content:"";
}
.pesudo:after{
  position: absolute;
  top: 0; 
  right: 0; 
  bottom: 0; 
  left: 0;
  z-index:-1;
  border-radius:1em;
  background:rgba(255,255,255,.2);
}
.pesudo:active:after{
  content:"";
}     
</style>
</head>
<body>
<div class="pesudo"></div>
</body>
</html>

相關文章