超炫酷CSS3垂直时间轴特效代码

超炫酷CSS3垂直时间轴特效代码

这是一款超炫酷CSS3垂直时间轴特效。该特效通过HTML DOM元素和CSS transform来制作非常炫酷的时间轴布局效果。

使用方法
在页面中引入fontawesome.min.css和bootstrap.min.css文件。

1
2
<link href="dist/bootstrap.min.css" rel="stylesheet">
<link href="dist/fontawesome.min.css" rel="stylesheet">

HTML结构
该垂直时间轴的HTML DOM元素结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="main-timeline">
                <div class="timeline">
                    <a href="#" class="timeline-content">
                        <div class="timeline-icon">
                            <i class="fa fa-globe"></i>
                        </div>
                        <div class="inner-content">
                            <h3 class="title">Web Designing</h3>
                            <p class="description">
                                Lorem ipsum dolor ..
                            </p>
                        </div>
                        <div class="timeline-year"><span>2018</span></div>
                    </a>
                </div>
                <div class="timeline">
                    <a href="#" class="timeline-content">
                        <div class="timeline-icon">
                            <i class="fa fa-rocket"></i>
                        </div>
                        <div class="inner-content">
                            <h3 class="title">Web Development</h3>
                            <p class="description">
                                Lorem ipsum dolor sit amet,..
                            </p>
                        </div>
                        <div class="timeline-year"><span>2017</span></div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

CSS样式
然后通过下面的CSS样式来制作垂直时间轴效果。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
.main-timeline{
    font-family: 'Roboto', sans-serif;
    padding: 20px 100px;
    overflow: hidden;
    position: relative;
}
.main-timeline .timeline{
    background-color: #fff;
   padding: 20px 70px 20px 20px;
    margin-bottom: 70px;
    border-radius: 0 100px 100px 0;
    position: relative;
    display: inline-block;
    z-index: 1;
}
.main-timeline .timeline:before{
    content: '';
    background-color: #fff;
   height: 240px;
    width: 240px;
    border-radius: 50%;
    transform: translateY(-50%);
    position: absolute;
    right: 0;
    top: 50%;
}
.main-timeline .timeline-content{
    color: #000;
   text-align: right;
    width: 95%;
    min-height: 160px;
    padding: 30px 170px 30px 180px;
    border: 2px solid #FD8881;
   display: block;
    float: left;
    position: relative;
}
.main-timeline .timeline-content:hover{ text-decoration: none; }
.main-timeline .timeline-icon{
    color: #808080;
   background-color: #e7e7e7;
   font-size: 80px;
    text-align: center;
    line-height: 130px;
    height: 130px;
    width: 160px;
    border-radius: 10px;
    transform: translateY(-50%);
    position: absolute;
    left: 13px;
    top: 50%;
}
.main-timeline .title{
    color: #808080;
   text-transform: capitalize;
    font-size: 25px;
    font-weight: 600;
    margin: 0 0 5px;
}
.main-timeline .description{
    color: rgba(0,0,0,0.5);
    font-size: 15px;
    letter-spacing: 1px;
    margin: 0;
}
.main-timeline .timeline-year{
    color: #fff;
   background: linear-gradient(60deg,#FF9389,#FF4E68);
   font-size: 70px;
    font-weight: 600;
    text-align: center;
    text-shadow: 2px 2px 5px #000;
   line-height: 200px;
    height: 200px;
    width: 200px;
    border-radius: 50%;
    overflow: hidden;
    transform: translateY(-50%);
    position: absolute;
    right: -95px;
    top: 50%;
}
.main-timeline .timeline-year:before,
.main-timeline .timeline-year:after{
    content: '';
    height: 190px;
    width: 190px;
    background-color: #fff;
   border-radius: 50%;
    position: absolute;
    left: 85px;
    top: 135px;
}
.main-timeline .timeline-year:after{
    border-radius: 0;
    transform: rotate(58deg);
    top: 144px;
    left: 116px;
    box-shadow: 0 0 8px #000;
}
.main-timeline .timeline:nth-child(even){
    border-radius: 100px 0 0 100px;
    padding: 20px 20px 20px 70px;
}
.main-timeline .timeline:nth-child(even) .timeline-icon{
    left: auto;
    right: 13px;
}
.main-timeline .timeline:nth-child(even) .timeline-content{
    padding: 20px 180px 20px 170px;
    text-align: left;
    float: right;
}
.main-timeline .timeline:nth-child(even):before{
    right: auto;
    left: 0;
}
.main-timeline .timeline:nth-child(even) .timeline-year{
    right: auto;
    left: -95px;
}
.main-timeline .timeline:nth-child(4n+2) .timeline-content{ border-color: #FDCC4C; }
.main-timeline .timeline:nth-child(4n+2) .timeline-year{
    background: linear-gradient(60deg,#FDCC4C,#FFF68D);
}
.main-timeline .timeline:nth-child(4n+3) .timeline-content{ border-color: #ADEEC3; }
.main-timeline .timeline:nth-child(4n+3) .timeline-year{
    background: linear-gradient(60deg,#ADEEC3,#83C796);
}
.main-timeline .timeline:nth-child(4n+4) .timeline-content{ border-color: #7AB8DD; }
.main-timeline .timeline:nth-child(4n+4) .timeline-year{
    background: linear-gradient(60deg,#7AB8DD,#A9E3F7);
}
@media screen and (max-width:1200px){
    .main-timeline{ padding: 20px 0 0; }
}
    @media screen and (max-width:990px){
    .main-timeline{ padding: 20px 0 0 0; }
    .main-timeline .timeline:nth-child(even),
    .main-timeline .timeline{
        border-radius: 0;
        padding: 20px;
        margin: 0 100px 60px 0;
    }
    .main-timeline .timeline:nth-child(even){ margin: 0 0 60px 100px; }
    .main-timeline .timeline:nth-child(even) .timeline-content,
    .main-timeline .timeline-content{
        padding: 20px 120px 20px 190px;
    }
    .main-timeline .timeline:nth-child(even) .timeline-content{ padding: 20px 190px 20px 120px; }
    .main-timeline .timeline:before{ right: -100px; }
    .main-timeline .timeline-year{
        right: -130px;
    }
    .main-timeline .timeline:nth-child(even):before{ left: -100px; }
    .main-timeline .timeline:nth-child(even) .timeline-year{
        left: -130px;
    }
}
@media screen and (max-width:767px){
    .main-timeline{ padding: 70px 0 0; }
    .main-timeline .timeline:nth-child(even),
    .main-timeline .timeline{
        border-radius: 0;
        padding: 15px;
        margin: 0 0 100px;
    }
    .main-timeline .timeline:nth-child(even) .timeline-content,
    .main-timeline .timeline-content{
        padding: 100px 30px 20px;
        text-align: center;
        width: 100%;
    }
    .main-timeline .timeline-icon{ display: none; }
    .main-timeline .timeline:nth-child(even):before,
    .main-timeline .timeline:before{
        display: block;
        right: 50%;
        top: -70px;
        transform: translateY(0) translateX(50%);
        height: 180px;
        width: 180px;
    }
    .main-timeline .timeline:nth-child(even):before{
        left: 50%;
        transform: translateY(0) translateX(-50%);
    }
    .main-timeline .timeline:nth-child(even) .timeline-year,
    .main-timeline .timeline-year{
        right: 50%;
        top: -70px;
        transform: translateY(0) translateX(50%);
        height: 150px;
        width: 150px;
        line-height: 150px;
        font-size: 50px;
    }
    .main-timeline .timeline-year:before{
        left: 30px;
        top: 100px;
    }
    .main-timeline .timeline-year:after{
        left: 65px;
        top: 106px;
        transform: rotate(67deg);
    }
    .main-timeline .timeline:nth-child(even) .timeline-year{
        left: 50%;
        transform: translateY(0) translateX(-50%);
    }
}
当前内容只有登录了才能查看,如果您已经注册,请登录
2

发表评论