![](/img/trans.png)
[英]Style ordered list adjacent to any heading with specific content with jQuery/JS
[英]Specific style on an ordered list
我需要一些幫助來整合2年前在草圖上制作的設計! 我們的目標是制作漂亮的訂購者清單,但我很難整合內容。
這是我到目前為止所做的:
HTML:
<div class="stepbar_block">
<ol class="stepbar_list">
<li class="stepbar_list_elem_active"> 50% </li>
<li class="stepbar_list_item">60% </li>
<li class="stepbar_list_item">70%</li>
<li class="stepbar_list_elem_current">80%</li>
<li class="stepbar_list_item">90%</li>
</ol>
</div>
CSS:
.stepbar_block {
margin: 0;
padding: 0;
counter-reset: step;
position: relative;
margin-top: 40px;
}
.stepbar_block:before {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
left : 30px;
top : -4px;
}
.stepbar_block:after {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
right : 30px;
top : -4px;
}
.stepbar_list li {
list-style-type: none;
float: left;
width: 20%;
height : 5px;
position: relative;
font-family: Roboto;
font-size: 10px;
line-height: 11px;
text-align: center;
color: rgba(87,87,86,0.5);
}
.stepbar_list:after {
content: '';
position: absolute;
height: 1px;
background-color: rgba(87,87,86,0.3);
left: 30px;
right: 30px;
z-index: 3;
}
.stepbar_list li:before {
content : '';
counter-increment: step;
width: 5px;
height: 5px;
border: 1px solid black;
display: block;
background-color : black;
border-radius: 40px;
text-align: center;
margin: -2px auto 10px auto;
}
.stepbar_list_item:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: white;
left: 0;
right: 0;
color: rgba(87,87,86,0.5);
font-size: 10px;
line-height: 11px; text-align: center;
}
.stepbar_list_elem_active:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: red;
left: 0;
right: 0;
}
.stepbar_list_elem_current:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: blue;
left: 0;
right: 0;
}
https://jsfiddle.net/zawt9hL6/
但是我能夠給項目着色而不是圓圈,所以我想知道缺少了什么,因為當我使用:before和:after時,似乎給整個列表項目而不是特定內容着色
那就是我想要的結果
可能有這樣的渲染? 而且,這是圈子里的漸變背景。
謝謝您的建議
全部使用這樣的東西。
.stepbar_list_elem_active:before {
width: 10px;
height: 10px;
background-color: #fff;
content: '';
position: absolute;
left: 0;
top: -6px;
border: 2px solid red;
border-radius: 50%;
right: 0;
margin: 0 auto;
}
您可以使用:before
和:after
偽元素來創建帶有漸變的圓。 首先,您可以只創建帶有漸變的規則圓,然后在第一個圓的頂部再添加一個帶有其他偽元素的白色圓。
10* { box-sizing: border-box; } ul { display: inline-flex; list-style: none; position: relative; padding: 0; margin: 0 50px; } ul:after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background: gray; } li { padding: 25px; position: relative; } li:after, li.color:before { position: absolute; content: ''; bottom: 0; left: 50%; height: 10px; width: 10px; background: gray; border-radius: 50%; transform: translate(-50%, 40%); z-index: 1; } li.color:after { width: 20px; height: 20px; transform: translate(-50%, 9px); } li.color:before { background: white; z-index: 2; width: 10px; height: 10px; } li.yellow:after { background: linear-gradient(to right, rgba(240,184,88,1) 0%, rgba(230,139,60,1) 38%, rgba(240,47,23,1) 71%, rgba(231,56,39,1) 100%); } li.blue:after { background: linear-gradient(to right, rgba(52,163,247,1) 0%, rgba(52,163,247,1) 32%, rgba(19,100,158,1) 71%, rgba(19,100,158,1) 100%); } .yellow { color: #ED4620; } .blue { color: #64A3D1; }
<ul> <li>1</li> <li class="color yellow">2</li> <li class="color blue">3</li> <li>4</li> </ul>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.