css3螞蟻線邊框程式碼例項

admin發表於2017-02-22
本章節分享一段程式碼例項,它實現了螞蟻線邊框效果。

程式碼如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
body {
  background-color: rgb(229, 201, 255);
}
.father {
  width: 280px;
  height: 180px;
  background-color: #fff;
  padding: 1px;
  background-image: -webkit-linear-gradient(-45deg,rgba(0, 0, 0, 1) 25%,rgba(0, 0, 0, 0) 25%,rgba(0, 0, 0, 0) 50%,rgba(0, 0, 0, 1) 50%,rgba(0, 0, 0, 1) 75%,rgba(0, 0, 0, 0) 75%,rgba(0, 0, 0, 0));
  background-size: 10px 10px;
  animation: myAnimation 0.8s linear;
  animation-iteration-count: infinite;
}
.child {
  width: 280px;
  height: 180px;
  background-color: rgba(255,255,255,1);
}
@keyframes myAnimation {
  0% {
    background-position: 0px 0px;
  }
  50% {
    background-position: 0px 5px;
  }
  100% {
    background-position: 0px 10px;
  }
}
</style>
</head>
<body>
<div class="father">
  <div class="child"></div>
</div>
</body>
</html>

相關文章