css3 时间轴动画
导读:CSS3的时间轴动画是一种神奇的动画效果,它可以让你的网站看起来更加生动、活泼。今天,我们来一起学习如何使用CSS3来创建时间轴动画效果。.timeline {position: relative;list-style: none;padd...
CSS3的时间轴动画是一种神奇的动画效果,它可以让你的网站看起来更加生动、活泼。今天,我们来一起学习如何使用CSS3来创建时间轴动画效果。
.timeline {
position: relative;
list-style: none;
padding: 0;
margin: 50px 0;
}
.timeline:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
width: 3px;
background-color: #dddddd;
left: 50%;
margin-left: -1.5px;
}
.timeline li {
position: relative;
margin-bottom: 50px;
}
.timeline li:before,.timeline li:after {
content: "";
display: table;
}
.timeline li:after {
clear: both;
}
.timeline li .timeline-panel {
width: 46%;
float: right;
padding: 30px;
position: relative;
text-align: right;
}
.timeline li .timeline-panel:before {
content: "";
position: absolute;
top: 26px;
right: -15px;
display: inline-block;
border-top: 15px solid transparent;
border-left: 15px solid #cccccc;
border-right: 0 solid #cccccc;
border-bottom: 15px solid transparent;
}
.timeline li .timeline-panel:after {
content: "";
position: absolute;
top: 27px;
right: -14px;
display: inline-block;
border-top: 14px solid transparent;
border-left: 14px solid #ffffff;
border-right: 0 solid #ffffff;
border-bottom: 14px solid transparent;
}
.timeline li .timeline-image {
width: 100px;
height: 100px;
left: 50%;
position: absolute;
margin-left: -50px;
z-index: 100;
border-radius: 50%;
background-color: #ffffff;
border: 7px solid #cccccc;
top: 15px;
}
.timeline li .timeline-image img {
width: 100%;
}
.timeline li .timeline-heading h4 {
margin-top: 0;
color: inherit;
}
.timeline li .timeline-heading h4.subheading {
margin-bottom: 0;
text-transform: none;
font-weight: normal;
}
.timeline li .timeline-body >
p,.timeline li .timeline-body >
ul {
margin-bottom: 0;
}
.timeline li:last-child .timeline-panel {
float: none;
width: 100%;
text-align: center;
}
.timeline li:last-child .timeline-image {
top: auto;
bottom: 0px;
margin-top: 15px;
}
.timeline li:last-child .timeline-image:before {
border-bottom-width: 0;
border-top-width: 15px;
top: -15px;
bottom: auto;
}
.timeline li:last-child .timeline-image:after {
border-bottom-width: 0;
border-top-width: 14px;
top: -14px;
bottom: auto;
}
代码中的.timeline类定义了整个时间轴的样式,包括列表、时间轴线以及每个时间轴的样式。
在HTML中,我们创建一个无序列表,并为每个列表项定义了一个.timeline-panel元素和一个.timeline-image元素。
列表项中,我们分别为.timeline-panel和.timeline-image定义了样式。.timeline-panel用来显示具体的事件信息,.timeline-image用来展示事件的图片。
到此为止,我们就创建了一个简单的时间轴效果。当然,你可以进一步改进这个时间轴的样式,以满足你的需求。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: css3 时间轴动画
本文地址: https://pptw.com/jishu/567394.html
