微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css3横向时间线

CSS3的横向时间线是一种在网页中展示时间轴的方式。它可以用来展示历史事件、项目进度、教育经历等信息。

css3横向时间线

实现横向时间线需要使用CSS的transform属性,其中translateX函数用于实现元素的水平移动。代码如下:

.time-line {
  position: relative;
  padding: 50px 0;
}

.time-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background-color: #ccc;
  transform: translateX(-50%);
}

.time-line-item {
  position: relative;
  width: 50%;
  margin: 50px auto;
}

.time-line-item::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ccc;
  transform: translateY(-50%);
}

.time-line-item::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -25px;
  width: 40px;
  height: 2px;
  background-color: #ccc;
  transform: translateY(-50%);
}

.time-line-item:first-child::after {
  display: none;
}

.time-line-item:last-child::before {
  display: none;
}

.time-line-year {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.time-line-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.time-line-desc {
  font-size: 14px;
  color: #666;
}

以上代码实现了一个基本的横向时间线,包含了时间轴、每个时间点的点和线、以及每个时间点的年份、标题和描述。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。