<div class="flow_steps">
<ul>
<li class="done">第一步</li>
<li class="current_prev">第二步</li>
<li class="current">第三步</li>
<li>第四步</li>
<li class="last">第五步</li>
</ul>
</div>
語義清晰:done(已完成)、current_prev(當前前置)、current(當前)、last(尾項)。
counter-reset/increment 自動生成步驟序號(可選)。::before 畫連接線,::after 畫圓點/狀態圖標。current、done 類名控制顏色變化(如:完成綠、當前藍、未開始灰)。flex 佈局均分寬度,響應式自適應。.flow_steps ul {
display: flex;
list-style: none;
padding: 0;
margin: 0;
position: relative;
}
.flow_steps li {
flex: 1;
text-align: center;
position: relative;
z-index: 1;
}
.flow_steps li::before {
content: '';
position: absolute;
top: 50%;
left: -50%;
width: 100%;
height: 2px;
background: #ddd; /* 未完成線色 */
transform: translateY(-50%);
z-index: -1;
}
.flow_steps li:first-child::before { display: none; }
.flow_steps li.done::before { background: #28a745; } /* 完成線色 */
.flow_steps li::after {
content: attr(data-step); /* 或用 counter */
width: 24px; height: 24px;
border-radius: 50%;
background: #fff;
border: 2px solid #ddd;
display: inline-flex;
align-items: center;
justify-content: center;
margin-bottom: 8px;
}
.flow_steps li.done::after {
background: #28a745;
border-color: #28a745;
color: #fff;
content: '✓';
}
.flow_steps li.current::after {
background: #007bff;
border-color: #007bff;
box-shadow: 0 0 0 4px rgba(0,123,255,.2);
}
步驟條不需複雜庫,語義化 HTML + 狀態類名 + 偽元素繪製,即可實現高性能、易維護的流程指示器。