时间轴HTML5代码
时间: 2023-12-20 20:29:53 浏览: 38
以下是一个简单的时间轴HTML5代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>时间轴示例</title>
<style>
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 2px;
background-color: #f00;
top: 0;
bottom: 0;
left: 50%;
margin-left: -1px;
}
.timeline-item {
padding: 10px;
position: relative;
background-color: #f1f1f1;
width: 50%;
margin-bottom: 20px;
}
.timeline-item::before {
content: '';
position: absolute;
border-radius: 50%;
border: 2px solid #f00;
background-color: #fff;
top: 15px;
left: -25px;
width: 20px;
height: 20px;
}
.timeline-item::after {
content: '';
position: absolute;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid #f1f1f1;
right: -10px;
top: 10px;
}
.timeline-item:last-child {
margin-bottom: 0;
}
.timeline-item:nth-child(even) {
float: right;
clear: both;
margin-right: 10%;
}
.timeline-item:nth-child(even)::before {
left: auto;
right: -25px;
}
.timeline-item:nth-child(even)::after {
border-left-color: #fff;
right: auto;
left: -10px;
}
</style>
</head>
<body>
<div class="timeline">
<div class="timeline-item">
<h3>2010</h3>
<p>这是2010年的事件描述。</p>
</div>
<div class="timeline-item">
<h3>2012</h3>
<p>这是2012年的事件描述。</p>
</div>
<div class="timeline-item">
<h3>2015</h3>
<p>这是2015年的事件描述。</p>
</div>
<div class="timeline-item">
<h3>2018</h3>
<p>这是2018年的事件描述。</p>
</div>
</div>
</body>
</html>
```