【发布时间】:2020-12-20 04:03:18
【问题描述】:
我正在尝试创建一个有序的任务列表。随着每项任务的完成,任务变为绿色,线条变为实线。我正在为下面的静态示例寻求帮助。
我已经看到了一些这样做的例子,但我在线条和颜色方面遇到了困难。如果我将 ul li.circle:after 用于圆,将 ul li.circle:before 用于线,我可以将其连接起来,但它们都变成实线,我无法弄清楚如何与虚线互换。我想使用列表项来定义线条和圆圈的颜色。
在 css 中有 padding: 0 0 20px 50px;这就是为什么线条没有按照需要连接到点,但是没有填充,之间没有间距。要更改颜色,我可以使用 before/after 更改所有的颜色,但我不能为颜色添加另一个类,如下所示。
开始的 css 类应该是一条带顶部的线,如字母 T,并且 arrowDown 应该有一个连接到虚线的词干。
CSS 文件和页面布局:
.red {
background: #ff0000;
}
.green {
background: #00ff00;
}
.start {
/* polygon? T like shape*/
}
ul {
max-width: 400px;
margin: 0 auto;
list-style-type: none;
margin: 0;
font-family: sans-serif;
color: #ffffff;
}
ul li {
padding: 0 0 20px 50px;
position: relative;
margin: 0;
}
/* Circle */
ul li.circle:after {
position: absolute;
color: #ccc;
top: 0;
left: 0;
content: '';
border: 2px solid #fff;
border-radius: 50%;
height: 24px;
width: 24px;
text-align: center;
line-height: 24px;
background: #000000;
}
/* Circle
ul li.circle:before {
position: absolute;
left: 10px;
top: 0px;
content: "";
height: 100%;
width: 0;
border-left: 2px solid #ffffff;
}
*/
/* Line */
ul li.line:before {
position: absolute;
left: 10px;
top: 0px;
content: "";
height: 100%;
width: 0;
border-left: 2px solid #ffffff;
}
/* dottedLine */
ul li.dottedLine:before {
position: absolute;
left: 10px;
top: 0px;
content: "";
height: 100%;
width: 0;
border-left: 2px dotted #ffffff;
}
/* Missing the stem */
ul li.arrowDown:after {
position: absolute;
transform: rotate(45deg);
top: 10px;
left: 4px;
content: '';
display: inline-block;
text-align: center;
line-height: 24px;
border: solid #ffffff;
border-width: 0px 3px 3px 0px;
display: inline-block;
padding: 6px;
}
<li>
<li class="start">Monday</li>
<li class="line"></li>
<li class="circle green">Task 1</li>
<li class="line"></li>
<li class="circle green">Task 2</li>
<li class="dottedLine"></li>
<li class="circle red">Task 3</li>
<li class="dottedLine"></li>
<li class="arrowDown">Tuesday</li>
</ul>
请参阅附件以获取上面所需的输出。 enter image description here
【问题讨论】:
-
您能否向我们展示您正在努力实现的目标?如果我们能看到您想要做什么,这将对我们有所帮助:)
标签: html css list class html-lists