✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 HTML CSS 和 JAVASCRIPT
来源:dev.to
时间:2024-12-29 12:24:35 144浏览 收藏
最近发现不少小伙伴都对文章很感兴趣,所以今天继续给大家介绍文章相关的知识,本文《✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 HTML CSS 和 JAVASCRIPT》主要内容涉及到等等知识点,希望能帮到你!当然如果阅读本文时存在不同想法,可以在评论中表达,但是请勿使用过激的措辞~

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Disco Bulb Animation</title>
<style>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(45deg, #000000, #111111);
font-family: Arial, sans-serif;
}
.container {
display: flex;
gap: 200px;
}
.wall {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 300px;
padding: 15px;
border-radius: 10px;
background: rgba(96, 95, 95, 0.281);
backdrop-filter: blur(10px);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.bulb {
width: 60px;
height: 60px;
background: rgba(255, 255, 255, 0.1);
border: 2px solid rgba(255, 255, 255, 0.2);
border-radius: 50%;
backdrop-filter: blur(10px);
box-shadow: 0 0 5px rgba(255, 255, 255, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.1);
transition: box-shadow 0.3s, background-color 0.3s;
}
.bulb.glow {
animation: disco 0.2s infinite alternate;
}
@keyframes disco {
0% {
background-color: rgba(255, 0, 128, 0.8);
box-shadow: 0 0 40px 40px rgba(255, 0, 128, 0.8);
}
25% {
background-color: rgba(0, 255, 128, 0.8);
box-shadow: 0 0 30px 10px rgba(0, 255, 128, 0.8);
}
50% {
background-color: rgba(0, 128, 255, 0.8);
box-shadow: 0 0 30px 10px rgba(0, 128, 255, 0.8);
}
75% {
background-color: rgba(255, 255, 0, 0.8);
box-shadow: 0 0 30px 10px rgba(255, 255, 0, 0.8);
}
100% {
background-color: rgba(255, 128, 0, 0.8);
box-shadow: 0 0 30px 10px rgba(255, 128, 0, 0.8);
}
}
.start-button {
position: absolute;
bottom: 50px;
padding: 15px 30px;
background: #ff5722;
color: white;
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 18px;
font-weight: bold;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
transition: background 0.3s;
}
.start-button:hover {
background: #ff784e;
}
</style>
</head>
<body>
<div class="container">
<div class="wall">
<div class="bulb" id="left-bulb-1"></div>
<div class="bulb" id="left-bulb-2"></div>
<div class="bulb" id="left-bulb-3"></div>
</div>
<div class="wall">
<div class="bulb" id="right-bulb-1"></div>
<div class="bulb" id="right-bulb-2"></div>
<div class="bulb" id="right-bulb-3"></div>
</div>
</div>
<button class="start-button" onclick="startDisco()">
Start</button>
<script>
async function startDisco() {
const leftBulbs = [
document.getElementById("left-bulb-1"),
document.getElementById("left-bulb-2"),
document.getElementById("left-bulb-3"),
];
const rightBulbs = [
document.getElementById("right-bulb-1"),
document.getElementById("right-bulb-2"),
document.getElementById("right-bulb-3"),
];
// Function to glow a bulb for 3 seconds
async function glowBulb(bulb) {
bulb.classList.add("glow");
await new Promise((resolve) =>
setTimeout(resolve, 3000));
bulb.classList.remove("glow");
}
// Glow bulbs on the left wall
for (let bulb of leftBulbs) {
await glowBulb(bulb);
}
// Glow bulbs on the right wall
for (let bulb of rightBulbs) {
await glowBulb(bulb);
}
}
</script>
</body>
</html>
以上就是《✨ 带有玻璃变形效果的发光迪斯科灯泡动画! ✨ 代码 HTML CSS 和 JAVASCRIPT》的详细内容,更多关于的资料请关注golang学习网公众号!
声明:本文转载于:dev.to 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
501 收藏
最新阅读
更多>
-
322 收藏
-
462 收藏
-
291 收藏
-
100 收藏
-
431 收藏
-
267 收藏
-
334 收藏
-
105 收藏
-
423 收藏
-
400 收藏
-
169 收藏
-
235 收藏
课程推荐
更多>
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 543次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 516次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 500次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 485次学习