css动态背景特效
时间: 2023-07-25 09:09:10 浏览: 167
CSS3动态方块背景登录页面特效.zip
下面是一些常见的 CSS 动态背景特效:
1. 渐变背景动画
```css
body {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
```
2. 粒子背景动画
```css
body {
background: black;
}
#particles-js {
position: absolute;
width: 100%;
height: 100%;
background-color: #b61924;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
z-index: 1;
}
<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script>
particlesJS("particles-js", {
particles: {
number: { value: 80, density: { enable: true, value_area: 800 } },
color: { value: "#ffffff" },
shape: {
type: "circle",
stroke: { width: 0, color: "#000000" },
polygon: { nb_sides: 5 },
image: { src: "img/github.svg", width: 100, height: 100 },
},
opacity: {
value: 0.5,
random: false,
anim: { enable: false, speed: 1, opacity_min: 0.1, sync: false },
},
size: {
value: 3,
random: true,
anim: { enable: false, speed: 40, size_min: 0.1, sync: false },
},
line_linked: {
enable: true,
distance: 150,
color: "#ffffff",
opacity: 0.4,
width: 1,
},
move: {
enable: true,
speed: 6,
direction: "none",
random: false,
straight: false,
out_mode: "out",
bounce: false,
attract: { enable: false, rotateX: 600, rotateY: 1200 },
},
},
interactivity: {
detect_on: "canvas",
events: {
onhover: { enable: true, mode: "repulse" },
onclick: { enable: true, mode: "push" },
resize: true,
},
modes: {
grab: { distance: 400, line_linked: { opacity: 1 } },
bubble: { distance: 400, size: 40, duration: 2, opacity: 8, speed: 3 },
repulse: { distance: 200, duration: 0.4 },
push: { particles_nb: 4 },
remove: { particles_nb: 2 },
},
},
retina_detect: true,
});
</script>
```
3. 雷达动画
```css
body {
background: #0c0f17;
}
#radar {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #131722;
overflow: hidden;
}
#radar::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: radial-gradient(ellipse at center, transparent 0%, #131722 0.5%, #131722 100%);
transform: scale(1.5);
opacity: 0.5;
filter: blur(10px);
}
#radar::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 40px;
height: 40px;
margin: -20px 0 0 -20px;
border-radius: 50%;
background-color: #00c6ff;
box-shadow: 0 0 10px rgba(0, 198, 255, 0.5), 0 0 20px rgba(0, 198, 255, 0.5), 0 0 30px rgba(0, 198, 255, 0.5), 0 0 40px rgba(0, 198, 255, 0.5);
animation: radar 3s linear infinite;
}
@keyframes radar {
0% {
transform: scale(1);
opacity: 1;
box-shadow: 0 0 10px rgba(0, 198, 255, 0.5), 0 0 20px rgba(0, 198, 255, 0.5), 0 0 30px rgba(0, 198, 255, 0.5), 0 0 40px rgba(0, 198, 255, 0.5);
}
100% {
transform: scale(2);
opacity: 0;
box-shadow: 0 0 10px rgba(0, 198, 255, 0), 0 0 20px rgba(0, 198, 255, 0), 0 0 30px rgba(0, 198, 255, 0), 0 0 40px rgba(0, 198, 255, 0);
}
}
```
希望对你有所帮助!
阅读全文