Skip to content

Commit c727ad3

Browse files
committed
css实现锯齿时间线
1 parent 57b9742 commit c727ad3

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>锯齿时间线</title>
8+
<style>
9+
.timeline-item {
10+
position: relative;
11+
border-bottom: 1px solid #71717a;
12+
width: 50%;
13+
margin: 0 auto;
14+
min-height: 100px;
15+
padding: 0px 20px;
16+
}
17+
/* 绘制圆点样式 */
18+
.timeline-item::after {
19+
content: "";
20+
position: absolute;
21+
top: 50%;
22+
height: 2rem;
23+
width: 2rem;
24+
border-radius: 50%;
25+
background: #71717a;
26+
background-color: red;
27+
}
28+
/* 偶数项,画左边线 */
29+
.timeline-item:nth-child(2n){
30+
border-left: 1px solid #71717a;
31+
}
32+
/* 偶数项,圆点位置 靠左垂直居中 */
33+
.timeline-item:nth-child(2n)::after {
34+
left: 0;
35+
transform: translate(-50%,-50%);
36+
}
37+
/* 奇数项,画右边线 */
38+
.timeline-item:nth-child(2n + 1) {
39+
border-right: 1px solid #71717a;
40+
}
41+
/* 奇数项,圆点位置 靠右垂直居中 */
42+
.timeline-item:nth-child(2n + 1)::after{
43+
right: 0;
44+
transform: translate(50%,-50%);
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<div class="timeline-item">......</div>
50+
<div class="timeline-item">......</div>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)