我试图使用CSS和HTML的组合重新创建此图像,没有运气.请指教.
现行代码:
.lens-profile-timeline {
list-style: none;
padding: 0;
margin: 60px 0 80px;
border-bottom: 8px solid #39752c;
position: relative;
}
.lens-profile-timeline li {
position: absolute;
width: 16px;
height: 16px;
border: 13px solid #39752c;
border-radius: 16px;
background: #fff;
margin-top: -10px;
margin-left: 20px;
margin-right: 20px;
}
.lens-profile-timeline time,
.lens-profile-timeline p {
left: -27px;
top: -40px;
position: absolute;
width: 70px;
text-align: center;
}
.lens-profile-timeline time {
margin-top: 70px;
font-size: 18px;
}
.lens-profile-timeline p {
margin-top: -0px;
font-size: 10px;
line-height: 1.1;
}
.lens-profile-timeline p:after {
content: "";
height: 8px;
border-left: 1px solid #39752c;
position: absolute;
bottom: -10px;
left: 35px;
}
-
-
-
Current Year
上面表示用于生成图像的当前代码.但是你会注意到有几个缺少的元素.
您可以使用伪元素,CSS三角形和线性渐变的组合来实现.
该linear-gradient(to right, #AFCB6D, #126A38);
会创建一个混合的背景颜色效果.
最后的三角形可以使用CSS三角形概念使用伪元素创建.
指标也是用伪元素圆圈创建的.可以content: " "
在伪元素中指定或删除伪元素,并在其中指定文本div
以便更好地进行自定义.
不使用CSS内容的常规文本:
.timeline {
width: 500px;
height: 10px;
margin: 20px;
background: linear-gradient(to right, #AFCB6D, #126A38);
position: relative;
font-family: Roboto;
}
.timeline::before,
.timeline::after {
content: " ";
position: absolute;
height: 0px;
width: 0px;
top: -5px;
}
.timeline::before {
left: -20px;
border: 10px solid #AFCB6D;
border-color: transparent #AFCB6D transparent transparent;
}
.timeline::after {
right: -20px;
border: 10px solid #126A38;
border-color: transparent transparent transparent #126A38;
}
.indicators {
position: relative;
}
.indicator-1,
.indicator-2,
.indicator-3 {
border: 5px solid #AFCB6D;
background: white;
border-radius: 50%;
width: 10px;
height: 10px;
top: -5px;
position: absolute;
}
.indicator-1 {
left: 10px;
}
.indicator-2 {
border-color: #5B9951;
left: 240px;
}
.indicator-3 {
border-color: #126A38;
left: 475px;
}
.indicator-text {
position: relative;
top: 15px;
}
.indicator-1 .indicator-text {
left: -20px;
}
.indicator-2 .indicator-text {
left: -15px;
}
.indicator-3 .indicator-text {
left: -10px;
}
Standard
Better
Best