步骤进度条 - 在进度数字框之间的线条
创始人
2025-01-12 14:30:20
0

以下是一个使用HTML、CSS和JavaScript创建步骤进度条的示例代码:

HTML代码:

Step 1
Step 2
Step 3
Step 4

CSS代码:

.progress-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 400px;
  height: 40px;
  background-color: #ccc;
  border-radius: 20px;
  padding: 5px;
}

.step {
  width: 75px;
  height: 30px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.step.active {
  background-color: #007bff;
  color: #fff;
}

JavaScript代码:

const steps = document.querySelectorAll('.step');

steps.forEach((step, index) => {
  step.addEventListener('click', () => {
    updateProgress(index);
  });
});

function updateProgress(selectedIndex) {
  steps.forEach((step, index) => {
    if (index <= selectedIndex) {
      step.classList.add('active');
    } else {
      step.classList.remove('active');
    }
  });
}

这个示例中,我们使用flex布局创建了一个进度条的容器,并在容器中放置了几个步骤。每个步骤都是一个带有文本的div元素,并且在点击时会更新进度条的状态。

CSS样式用于设置进度条和步骤的外观,包括背景颜色、边框、圆角等。

JavaScript代码用于处理点击事件,当点击某个步骤时,会调用updateProgress函数来更新进度条的状态。在updateProgress函数中,我们遍历所有的步骤,并根据其索引与选中的步骤索引进行比较,添加或移除active类来设置步骤的激活状态。

你可以根据需要修改HTML、CSS和JavaScript代码来适应你的实际情况。

上一篇:步骤进度条

下一篇:步骤进度条 ExtJs

相关内容

热门资讯

透视规律(wepoker)we... 透视规律(wepoker)wepoker透视破解版(透视)真是是有挂(玩家教你)1、许多玩家不知道w...
透视系统(WePoKer)we... 透视系统(WePoKer)wepoker买脚本靠谱吗(透视)原来是有挂(wepoke教程)1、全新机...
透视黑科技(WePoKer)w... 透视黑科技(WePoKer)wepoker私局辅助(透视)本来存在有挂(透明挂教程)wepoker私...
透视辅助(WEPOKER)we... 透视辅助(WEPOKER)wepoker软件辅助程序(透视)本来有挂(wpk教程);1、wepoke...
透视软件(wepoker)we... 透视软件(wepoker)we poker辅助器(透视)切实存在有挂(细节揭秘);1、在we pok...
透视脚本(WePoKer)we... 透视脚本(WePoKer)wepoker私人局规律(透视)总是真的是有挂(透明挂教程)1、在wepo...
透视工具(WEPOKER)we... 透视工具(WEPOKER)wepokerplus脚本(透视)好像是有挂(AI教程)1、首先打开wep...
透视能赢(WEPOKER)we... 透视能赢(WEPOKER)wepoker脚本(透视)切实是真的有挂(解密教程)1、下载好wepoke...
透视智能ai(WePoKer)... 透视智能ai(WePoKer)htx矩阵wepoker辅助(透视)真是有挂(技巧教程)1、打开软件启...
透视了解(wepoker)we... 透视了解(wepoker)wepoker怎么看底牌(透视)切实有挂(必备教程)1、任何wepoker...