CSS3滑鼠懸浮交叉線效果按鈕

螞蟻小編發表於2017-02-27

分享一段程式碼例項,它實現了滑鼠出現交叉線效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
.carDCButton {
  width: 150px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-weight: bold;
  background-color: #027ebf;
  position: relative;
  cursor: pointer;
  font-size: 14px;
  color: #fff;
}
.carDCButton a {
  display: block;
  cursor: pointer;
}
.carDCButton a:hover .R-left {
  width: 198px;
  left: 0;
}
.carDCButton a:hover .R-right {
  width: 198px;
  right: 0;
}
.carDCButton a:hover .R-top {
  height: 46px;
  top: 0;
}
.carDCButton a:hover .R-bottom {
  height: 46px;
  bottom: 0;
}
.carDCButton a span {
  position: absolute;
  background: #027ebf;
  z-index: 1;
}
.carDCButton a .R-left {
  top: 0;
  left: -110%;
  transition: left 0.3s;
  width: 0;
  height: 1px;
}
.carDCButton a .R-right {
  bottom: 0;
  right: -110%;
  transition: right 0.3s;
  width: 0;
  height: 1px;
}
.carDCButton a .R-top {
  top: -110%;
  left: -1px;
  transition: top 0.3s;
  height: 0;
  width: 1px;
}
.carDCButton a .R-bottom {
  bottom: -110%;
  right: -1px;
  transition: bottom 0.3s;
  height: 0;
  width: 1px;
}
</style>
</head>
<body>
<div class="carDCButton">
  <a>
    <span class="R-left"></span><span class="R-right"></span>
    <span class="R-top"></span><span class="R-bottom"></span>
    螞蟻部落
  </a>
</div>
</body>
</html>

相關文章