当前位置: 首页 > news >正文

炫酷圆形按钮调色器

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>圆形按钮颜色控制器</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}

.container {
text-align: center;
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 300px;
}

.display-button {
width: 40px;
height: 40px;
border-radius: 50%;
margin: 20px auto;
background-color: #cccccc;
border: none;
cursor: default;
transition: all 0.3s ease;
box-shadow: 
0 4px 8px rgba(0, 0, 0, 0.1),
inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.control-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}

.control-button {
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
color: white;
transition: all 0.2s ease;
}

.control-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button:active {
transform: translateY(0);
}

#button1 {
background-color: #e74c3c;
}

#button2 {
background-color: #e67e22;
}

#button3 {
background-color: #2ecc71;
}

/* 状态类 */
.red {
background-color: #e74c3c !important;
box-shadow: 
0 4px 12px rgba(231, 76, 60, 0.4),
inset 0 0 10px rgba(0, 0, 0, 0.1) !important;
}

.orange {
background-color: #e67e22 !important;
box-shadow: 
0 4px 12px rgba(230, 126, 34, 0.4),
inset 0 0 10px rgba(0, 0, 0, 0.1) !important;
}

.green {
background-color: #2ecc71 !important;
box-shadow: 
0 4px 12px rgba(46, 204, 113, 0.4),
inset 0 0 10px rgba(0, 0, 0, 0.1) !important;
}
</style>
</head>
<body>
<div class="container">
<h2>按钮颜色控制器</h2>
<button class="display-button" id="displayBtn"></button>
<div class="control-buttons">
<button class="control-button" id="button1">红色</button>
<button class="control-button" id="button2">橙色</button>
<button class="control-button" id="button3">绿色</button>
</div>
</div>

    <script>
// 获取DOM元素
const displayBtn = document.getElementById('displayBtn');
const button1 = document.getElementById('button1');
const button2 = document.getElementById('button2');
const button3 = document.getElementById('button3');

// 移除所有颜色类
function resetColors() {
displayBtn.classList.remove('red', 'orange', 'green');
}

// 按钮事件监听
button1.addEventListener('click', function() {
resetColors();
displayBtn.classList.add('red');
displayBtn.textContent = "红色状态";
});

button2.addEventListener('click', function() {
resetColors();
displayBtn.classList.add('orange');
displayBtn.textContent = "橙色状态";
});

button3.addEventListener('click', function() {
resetColors();
displayBtn.classList.add('green');
displayBtn.textContent = "绿色状态";
});
</script>
</body>
</html>

运行效果:

http://www.lryc.cn/news/612907.html

相关文章:

  • Ubuntu 系统 Docker 启动失败(iptables/nf\_tables)
  • 应急响应复现
  • Android 原生与 Flutter 通信完整实现 (Kotlin 版)
  • JPA 分页查询与条件分页查询
  • 《深入理解 WSGI:解锁 Python Web 应用背后的奥秘》
  • Java+Vue合力开发固定资产条码管理系统,移动端+后台管理,集成资产录入、条码打印、实时盘点等功能,助力高效管理,附全量源码
  • 前端性能优化:从请求到资源的精细调控
  • Event Stream输出优化:Vue3节流函数的正确实现
  • 【大前端】vite忽略指定前缀的静态资源
  • 【插件式微服务架构系统分享】之 解耦至上:gateway 网关与APISIX 网关的不同分工
  • 一文解读“Performance面板”前端性能优化工具基础用法!
  • SpringAI
  • 数据结构---循环队列(补充 应用实例)、哈希表(哈希存储、哈希冲突、解决方法、举例实现)
  • Linux Docker 新手入门:一文学会配置镜像加速器
  • 躺平发育小游戏微信抖音流量主小程序开源
  • 透明矿山:科技重塑矿业未来
  • Numpy科学计算与数据分析:Numpy随机数生成入门
  • 光纤滑环 – 光纤旋转接头(FORJ)- 杭州驰宏科技
  • AutoMQ-Kafka的替代方案实战
  • QML与C++交互的方式
  • Kafka数据生产和发送
  • 基于Spring Cloud Stream与Kafka的事件驱动微服务架构设计与实战指南
  • 【Kafka系列】第二篇| Kafka 的核心概念、架构设计、底层原理
  • MQTT:Dashboard访问授权
  • MQTT:Dashboard黑名单与连接抖动
  • 【LeetCode】set和map相关算法题 前K个高频单词、随机链表的复制、两个数组的交集、环形链表
  • Flink-1.19.0源码详解9-ExecutionGraph生成-后篇
  • VScode使用jupyter notebook,配置内核报错没有torch解决
  • 贪心算法分析与解决指南
  • 1.电动汽车动力电池系统技术介绍与分类