css3如何实现一个雷达扫描的效果呢?


摘要:
下文讲述使用css3编写一个雷达扫描的方法分享,如下所示:


实现思路:
使用css动画无限循环播放

例:
实现一个雷达图


 
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.maomao365.com/" />
<title>猫猫教程(www.maomao365.com)
雷达扫描css示例
</title>
<style>
*{
  padding:0;
  margin:0;
}
body{
  background-color:white;
}
.radar{
  width:300px;
  height:300px;
  border-radius:50%;
  box-shadow:blue 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,39,175) 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:blue 0 0 0 1px;
}
.lineX{
  width:300px;
  height:1px;
  background-color:blue;
  position:absolute;
  top:50%;
}
.lineY{
  width:1px;
  height:300px;
  background-color:blue;
  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>
css 雷达扫描图效果

css 雷达扫描图效果