Angularjs切换网站配色模式简单示例2(切换body元素的class)

一个网站可以有多种配色方案,例如正常模式,夜间模式等。

简单示例一个通过点击toggle 按钮,切换body元素的class,达到切换配色模式的angularjs小app。

1. Live范例可以在以下Codepen网址查看: http://codepen.io/ChristyWang/pen/NPxNMx

2. Toggle button源代码由以下网站生成:https://proto.io/freebies/onoff/


3. 主要文件有两个:index.html和main.css。<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的代码示例,实现了在一个盒子中装下四个模块,点击可跳转页面。配色为蓝色和灰色,简洁大方: ```html <!DOCTYPE html> <html> <head> <title>模块</title> <style> .container { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; height: 500px; background-color: #f2f2f2; } .module { width: 200px; height: 200px; margin: 20px; padding: 20px; background-color: #fff; border-radius: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: all 0.3s ease-in-out; cursor: pointer; } .module:hover { transform: translateY(-5px); box-shadow: 0 5px 10px rgba(0,0,0,0.3); } .module h2 { margin-top: 0; font-size: 24px; color: #333; } .module p { font-size: 16px; color: #666; } .repair { background-color: #4a90e2; color: #fff; } .maintenance { background-color: #6ab04c; color: #fff; } .parts { background-color: #f5a623; color: #fff; } .other { background-color: #d0021b; color: #fff; } </style> </head> <body> <div class="container"> <div class="module repair" onclick="location.href='repair.html';"> <h2>故障报修模块</h2> <p>点击进入故障报修页面</p> </div> <div class="module maintenance" onclick="location.href='maintenance.html';"> <h2>设备维修模块</h2> <p>点击进入设备维修页面</p> </div> <div class="module parts" onclick="location.href='parts.html';"> <h2>配件更换模块</h2> <p>点击进入配件更换页面</p> </div> <div class="module other" onclick="location.href='other.html';"> <h2>其他问题模块</h2> <p>点击进入其他问题页面</p> </div> </div> </body> </html> ``` 这段代码使用了 flex 布局,让四个模块在一个盒子中居中对齐,并且自动换行。每个模块都是一个 div,里面包含一个标题和一段文本,点击 div 会跳转到对应页面。每个模块的背景色和文本颜色不同,以区分不同的模块。鼠标悬停在模块上时,会有一些动画效果,使页面更加生动。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值