CSS3雷達掃描效果

admin發表於2017-02-20

本章節分享一段程式碼例項,它使用css3實現了雷達掃描效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
*{
  padding:0;
  margin:0;
}
body{
  background-color:#f0f0f0;
}
.radar{
  width:300px;
  height:300px;
  border-radius:50%;
  box-shadow:#0C840C 0 0 0 1px;
  position:absolute;
  left:50%;
  top:50%;
  margin:-150px;
}
.laserLine{
  width:150px;
  height:300px;
  overflow:hidden;
  position:absolute;
  left:50%;
  top:50%;
  margin:-150px;
  transform-origin:150px 150px;
  animation-name:scan;
  animation-duration:5s;
  animation-timing-function:linear;
  animation-iteration-count:infinite;
}
.laserLineInset{
  width:300px;
  height:300px;
  border-radius:50%;
  position:absolute;
  background-image:-webkit-linear-gradient(-30deg,rgba(0,0,0,0),rgba(255,0,0,0),rgb(5,113,1) 99%);
  clip:rect(0,150px,300px,0px);
  transform:rotate(135deg);
}
.radarIn{
  width:150px;
  height:150px;
  position:absolute;
  top:50%;
  left:50%;
  border-radius:50%;
  margin:-75px;
  box-shadow:#0C840C 0 0 0 1px;
}
.lineX{
  width:300px;
  height:1px;
  background-color:#0C840C;
  position:absolute;
  top:50%;
}
.lineY{
  width:1px;
  height:300px;
  background-color:#0C840C;
  position:absolute;
  left:50%;
}
@keyframes scan{
  0%{
    transform:rotate(0deg);
  }
  100%{
    transform:rotate(-360deg);
  }
}
</style>
</head>
<body>
<div class="radar">
  <div class="lineX"></div>
  <div class="lineY"></div>
  <div class="radarIn"></div>
  <div class="laserLine">
    <div class="laserLineInset"></div>
  </div>
</div>
</body>
</html>

相關文章