原生js+css实现可配置参数光晕动画效果代码
代码语言:html
所属分类:动画
代码描述:原生js+css实现可配置参数光晕动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>可配置的炫酷光晕动画</title>
<style>
/* --- 基础样式 --- */
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
background-color: #0c0c1e; /* 深邃的午夜蓝色背景 */
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #fff;
}
/* --- 动画容器 --- */
.animation-container {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.5)); /* 给整体增加一点辉光 */
}
/*
* 为了实现旋转和缩放动画不冲突,我们使用一个包装器来处理旋转,
* 内部的圆环处理脉冲(缩放)动画。
*/
.halo-rotator {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.halo-ring {
border-radius: 50%;
border: 2px solid;
/* 核心动画:脉冲效果 */
animation-name: pulse;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
/* --- 关键帧动画 --- */
@keyframes pulse {
0%, 100% {
transform: scale(0.8);
opacity: 0.6;
}
50% {
transform: scale(1.1);
opacity: 1;
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/* --- 控制面板样式 --- */
.controls-panel {
position: absolute;
top: 20px;
right: 20px;
padding: 20px;
background: rgba(20, 20, 40, 0.7);
border-radius: 12px;
border: 1px solid rgba(100, 100, 200, 0.3);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px); /* 兼容 Safari */
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0