成都网站建设学习,网站建设哪家性价比高,郑州男科医院哪家治疗比较好,威海网站建设大家好#xff0c;我是 Just#xff0c;这里是「设计师工作日常」#xff0c;今天分享的是使用 css 实现一个动态的雷达扫描#xff0c;快学起来吧#xff01;
《有趣的css》系列最新实例通过公众号「设计师工作日常」发布。 目录 整体效果核心代码html 代码css 部分代码…大家好我是 Just这里是「设计师工作日常」今天分享的是使用 css 实现一个动态的雷达扫描快学起来吧
《有趣的css》系列最新实例通过公众号「设计师工作日常」发布。 目录 整体效果核心代码html 代码css 部分代码 完整代码如下html 页面css 样式页面渲染效果 整体效果 知识点 ① animation 动画属性中 animation-direction 以及 steps() 参数的使用 思路 先绘制出整体大圆然后使用创建伪元素画出内里的小圆并加上虚线边框然后绘制出雷达层加上动画旋转再给雷达内增加几个闪烁的圆点最后外层套一个小动画边框。 核心代码部分简要说明了写法思路完整代码在最后可直接复制到本地运行。
核心代码
html 代码
div classleidabox50/div
div classleida50div classline50/divdiv classguangdian50span classdian50/span/div
/div雷达的主体。 css 部分代码
.leidabox50{width:220px;height:220px;border:4px solid rgba(0,0,0,0);border-top-color: #33B589;border-bottom-color: #33B589;border-radius:50%;position: absolute;animation:leidabox-eff-50 10s linear infinite;animation-direction:reverse;
}
keyframes leidabox-eff-50{to{transform:rotate(360deg);}
}
.leida50{width: 200px;height: 200px;display: flex;justify-content: center;align-items: center;position: relative;background-color: #31FFBA;border-radius: 50%;border: 1px solid #33B589;
}
.leida50:before,.leida50:after{content: ;width: 120px;height: 120px;border-radius: 50%;border: 1px dashed rgba(0,0,0,0.14);box-shadow: 0 0 20px rgba(0,0,0,0.1);position: absolute;z-index: 3;
}
.leida50:after{width: 60px;height: 60px;position: absolute;z-index: 10;
}
.line50{width: 100px;height: 100px;background-color: rgba(127,255,212,0.4);border-radius: 0 0 0 100%;position: absolute;left: 0;top: 100px;z-index: 100;animation: zhuaneff50 5s linear infinite;transform-origin: 100px 0;
}
.line50:after{content: ;width: 8px;height: 8px;background-color: rgba(255,255,255,0.6);position: absolute;top: -4px;right: -4px;border-radius: 50%;
}
keyframes zhuaneff50{to {transform: rotate(360deg);}
}
.guangdian50{position: absolute;bottom: 66px;
}
.dian50,.dian50:after,.dian50:before{width: 7px;height: 7px;background-color: #33B589;position: absolute;left: -20px;border-radius: 50%;animation: eff50 5s steps(6) infinite;z-index: 999;
}
.dian50:after{content: ;width: 6px;height: 6px;top: 12px;left: 44px;
}
.dian50:before{content: ;width: 3px;height: 3px;top: 40px;left: 34px;
}
keyframes eff50{0% {opacity: 0;transform: translate(0, 0);}25%{opacity: 1;transform: translate(-10px, -18px);}50%{opacity: 0;transform: translate(-18px, -20px);}75%{opacity: 1;transform: translate(-24px, -18px);}100%{opacity: 0;transform: translate(-34px, -24px);}
}
.guangdian50:after,.guangdian50:before{content: ;width: 6px;height: 6px;background-color: #33B589;position: absolute;top: -100px;left: 30px;border-radius: 50%;z-index: 900;animation: eff501 5s steps(6) both infinite;
}
.guangdian50:before{width: 7px;height: 7px;top: -20px;left: 40px;
}
keyframes eff501{0% {opacity: 0;}25%{opacity: 1;}50%{opacity: 0;}75%{opacity: 1;}100%{opacity: 0;}
}1、.leida50 画出最大的雷达圆形主体然后通过 .leida50:before 和 .leida50:after 伪元素创建里面的两个小圆并给两个小圆加上一点阴影效果。 2、.line50 绘制一个矩形并给它的一个角加上圆角 border-radius: 0 0 0 100%; 并通过 transform-origin 定位其原点加上动画旋转雷达就开始旋转扫描了 然后 利用 .line50:after 伪元素给中心加上一个固定点这样整体的雷达扫描区就完成了。 3、再在雷达主体上绘制几个移动的点利用 .dian50 、.dian50:after 和 .dian50:before 绘制 3 个大小不一的圆点并且定位到不同的位置然后通过加上 animation 动画设置 steps() 参数使这 3 个点边闪烁边移动。 4、然后再加上两个固定的圆点同样加上 animation 动画设置 steps() 参数让这 2 个圆点同前面的 3 个圆点同时闪烁。 5、在外层用 .leidabox50 绘制出两个半边框加上 animation 动画并设置 animation-direction 参数使反向旋转。 完整代码如下
html 页面
!DOCTYPE html
html langzhheadmeta charsetutf-8link relstylesheet hrefstyle.csstitle动态雷达扫描/title/headbodydiv classappdiv classleidabox50/divdiv classleida50div classline50/divdiv classguangdian50span classdian50/span/div/div/div/body
/htmlcss 样式
/** style.css **/
.app{width: 100%;height: 100vh;background-color: #ffffff;position: relative;display: flex;justify-content: center;align-items: center;
}
.leidabox50{width:220px;height:220px;border:4px solid rgba(0,0,0,0);border-top-color: #33B589;border-bottom-color: #33B589;border-radius:50%;position: absolute;animation:leidabox-eff-50 10s linear infinite;animation-direction:reverse;
}
keyframes leidabox-eff-50{to{transform:rotate(360deg);}
}
.leida50{width: 200px;height: 200px;display: flex;justify-content: center;align-items: center;position: relative;background-color: #31FFBA;border-radius: 50%;border: 1px solid #33B589;
}
.leida50:before,.leida50:after{content: ;width: 120px;height: 120px;border-radius: 50%;border: 1px dashed rgba(0,0,0,0.14);box-shadow: 0 0 20px rgba(0,0,0,0.1);position: absolute;z-index: 3;
}
.leida50:after{width: 60px;height: 60px;position: absolute;z-index: 10;
}
.line50{width: 100px;height: 100px;background-color: rgba(127,255,212,0.4);border-radius: 0 0 0 100%;position: absolute;left: 0;top: 100px;z-index: 100;animation: zhuaneff50 5s linear infinite;transform-origin: 100px 0;
}
.line50:after{content: ;width: 8px;height: 8px;background-color: rgba(255,255,255,0.6);position: absolute;top: -4px;right: -4px;border-radius: 50%;
}
keyframes zhuaneff50{to {transform: rotate(360deg);}
}
.guangdian50{position: absolute;bottom: 66px;
}
.dian50,.dian50:after,.dian50:before{width: 7px;height: 7px;background-color: #33B589;position: absolute;left: -20px;border-radius: 50%;animation: eff50 5s steps(6) infinite;z-index: 999;
}
.dian50:after{content: ;width: 6px;height: 6px;top: 12px;left: 44px;
}
.dian50:before{content: ;width: 3px;height: 3px;top: 40px;left: 34px;
}
keyframes eff50{0% {opacity: 0;transform: translate(0, 0);}25%{opacity: 1;transform: translate(-10px, -18px);}50%{opacity: 0;transform: translate(-18px, -20px);}75%{opacity: 1;transform: translate(-24px, -18px);}100%{opacity: 0;transform: translate(-34px, -24px);}
}
.guangdian50:after,.guangdian50:before{content: ;width: 6px;height: 6px;background-color: #33B589;position: absolute;top: -100px;left: 30px;border-radius: 50%;z-index: 900;animation: eff501 5s steps(6) both infinite;
}
.guangdian50:before{width: 7px;height: 7px;top: -20px;left: 40px;
}
keyframes eff501{0% {opacity: 0;}25%{opacity: 1;}50%{opacity: 0;}75%{opacity: 1;}100%{opacity: 0;}
}页面渲染效果 以上就是所有代码以及简单的思路希望对你有一些帮助或者启发。 [1] 原文阅读 CSS 是一种很酷很有趣的计算机语言在这里跟大家分享一些 CSS 实例 Demo为学习者获取灵感和思路提供一点帮助希望你们喜欢。
我是 Just这里是「设计师工作日常」求点赞求关注