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

css-50 Projects in 50 Days(2)

html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>步骤条</title><link rel="stylesheet" href="./index.css">
</head><body><div class="container"><div class="steps_wrapper "><div class="step step_active">1</div><div class="step">2</div><div class="step">3</div><div class="step">4</div><div class="line transition400" id="line"></div></div><div class="btn_wrapper transition400"><button class="btn " disabled id="pre">上一步</button><button class="btn " id="next">下一步</button></div></div><script src="./index.js"></script>
</body></html>

css

$primary: #24acf2;@mixin center {display: flex;align-items: center;justify-content: center;
}.transition400 {transition: all 400ms ease;
}.transition500 {transition: all 500ms ease;
}.container {@include center();flex-direction: column;height: 100vh;.steps_wrapper {display: flex;gap: 50px;position: relative;&::after,.line {content: '';position: absolute;left: 0;top: 50%;transform: translateY(-50%);width: 100%;height: 3px;background-color: #eee;z-index: -2;}.line {width: 0;background-color: $primary;z-index: -1;}.step {border-radius: 50%;border: 2px solid #e0e0e0;box-sizing: border-box;@include center();width: 30px;height: 30px;font-size: 14px;color: #999;background-color: #fff;}.step_active {background-color: $primary;color: #fff;border-color: $primary;transition: 0.4s 0.2s all ease;}}.btn_wrapper {display: flex;gap: 20px;margin-top: 36px;.btn {width: 90px;height: 32px;background-color: $primary;border: 1px solid $primary;border-radius: 8px;color: #fff;cursor: pointer;}.btn:active {transform: scale(0.98);opacity: 0.9;}.btn:disabled {cursor: not-allowed;background-color: #eee;border-color: #eee;}}
}

js

const state = {pre: document.getElementById('pre'),next: document.getElementById('next'),line: document.getElementById('line'),steps: document.querySelectorAll(`.step`),len: 4,cur: 0,process: {pre: () => {if (state.cur > 0) {state.cur--;}},next: () => {if (state.cur < state.len) {state.cur++;}}}
}state.pre.onclick = () => update('pre')
state.next.onclick = () => update('next')
function update(type) {// 增减操作state.process[type]()// 禁用上一步,下一步state.pre.disabled = false;state.next.disabled = false;if (state.cur == 0) {state.pre.disabled = true}if (state.cur + 1 == state.len) {state.next.disabled = true}// 设置样式setStyle()
}
function setStyle() {const step_actives = document.querySelectorAll('.step_active');step_actives.forEach(item => item.classList.remove('step_active'));state.line.style.width = `${(state.cur) * 33}%`;state.steps.forEach((item, i) => {if (i <= state.cur) {item.classList.add('step_active');}})
}


http://www.mrgr.cn/news/15357.html

相关文章:

  • 《深入浅出WPF》读书笔记.10资源
  • OSI七层模型中的数据链路层
  • HTML静态网页成品作业(HTML+CSS)——抗击疫情网页(4个页面)
  • OpenCV开发笔记(七十九):基于Stitcher类实现全景图片拼接
  • 【Python报错】AttributeError`:`‘NoneType‘ object has no attribute ‘XXXX‘`
  • 7-3 最长连续递增子序列--线性表
  • 121. 买卖股票的最佳时机
  • YOLOv9改进策略【损失函数篇】| 利用MPDIoU,加强边界框回归的准确性
  • Python爬虫(一文通)
  • 【知识】Pytorch中基于索引的操作
  • 数据库内容保密检查系统:及时发现“潜在”安全威胁
  • 【C++】仿照string类,实现myString
  • swf怎么转换成mp4格式?视频格式转换,就看这2个办法
  • 算法day15|513.找树左下角的值、112. 路径总和、113.路径总和Ⅱ、106.从中序与后序遍历序列构造二叉树、105.从前序与中序遍历序列构造二叉树
  • 【ceph学习】rgw网关进程如何启动
  • 网页正文提取算法:行块分布算法 Readability
  • 华清远见元宇宙实验中心,开启嵌入式、物联网与人工智能教学新篇章
  • Bonree ONE 3.0发布会下一站 9月6日广州见!
  • ts转mp4怎么转?分享3个方法,快速搞定
  • 深入理解Seaborn库的高级功能(二)