gpt4 book ai didi

javascript - 如何使用css制作垂直进度路径

转载 作者:行者123 更新时间:2023-11-29 17:01:34 30 4
gpt4 key购买 nike

我想知道如何使用 HTML、CSS 和 Js 制作进度条或更像进度路径

我找到了这个 here这绝对没问题,但我希望它在垂直方向上像这样在图像中 enter image description here

随着用户完成分配的任务而逐渐填充。或者如果有任何可用的图书馆,请告诉我。我搜索了很多,但没有找到满足我需要的东西。

最佳答案

@NGLN 的回答比我的简单,但我为它做了一个 fiddle 并添加了点亮节点的功能!

Check it out

var list = document.getElementById('progress'),
next = document.getElementById('next'),
clear = document.getElementById('clear'),
children = list.children,
completed = 0;

// simulate activating a node
next.addEventListener('click', function() {

// count the number of completed nodes.
completed = (completed === 0) ? 1 : completed + 2;
if (completed > children.length) return;

// for each node that is completed, reflect the status
// and show a green color!
for (var i = 0; i < completed; i++) {
children[i].children[0].classList.remove('grey');
children[i].children[0].classList.add('green');

// if this child is a node and not divider,
// make it shine a little more
if (i % 2 === 0) {
children[i].children[0].classList.add('activated');
}
}

}, false);

// clear the activated state of the markers
clear.addEventListener('click', function() {
for (var i = 0; i < children.length; i++) {
children[i].children[0].classList.remove('green');
children[i].children[0].classList.remove('activated');
children[i].children[0].classList.add('grey');
}
completed = 0;
}, false);
*, *:after, *:before { margin:0; padding:0; }
body {
padding: 15px;
font-family: Helvetica, sans-serif;
}

input[type="button"] {
margin-top: 20px;
}
.node {
height: 10px;
width: 10px;
border-radius: 50%;
display:inline-block;
transition: all 1000ms ease;
}

.activated {
box-shadow: 0px 0px 3px 2px rgba(194, 255, 194, 0.8);
}

.divider {
height: 40px;
width: 2px;
margin-left: 4px;
transition: all 800ms ease;
}

li p {
display:inline-block;
margin-left: 25px;
}

li {
list-style: none;
line-height: 1px;
}

.green{ background-color: rgba(92, 184, 92, 1); }
.grey { background-color: rgba(201, 201, 201, 1); }
<ul id="progress">
<li><div class="node grey"></div><p>The First Thing!</p></li>
<li><div class="divider grey"></div></li>
<li><div class="node grey"></div><p>The Second Thing!</p></li>
<li><div class="divider grey"></div></li>
<li><div class="node grey"></div><p>The Third Thing!</p></li>
<li><div class="divider grey"></div></li>
<li><div class="node grey"></div><p>The Fourth Thing!</p></li>
<li><div class="divider grey"></div></li>
<li><div class="node grey"></div><p>The Last Thing!</p></li>
</ul>
<input type="button" value="Next" id="next"/>
<input type="button" value="Clear" id="clear"/>

关于javascript - 如何使用css制作垂直进度路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27199566/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com