Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal timeline in pure css

Tags:

html

css

I'm trying to make a timeline in pure CSS however I seem to be running into some problems.

When I try to set the timeline div as overflow-x: scroll it still scrolls on the y access.

This is what I've got:

#timeline {
  height: 500px;
  width: auto;
  margin: 0;
  background: red;
}

.event {
  height: 500px;
}

.founded {
  width: 400px;
  float: left;
  background: blue;
}

.grant {
  width: 800px;
  background: yellow;
}
<ol id="timeline">
  <li class="event founded"></li>
  <li class="event grant"></li>
</ol>

I just want each additional entry to follow the previous one and for it all be scroll-able horizontally. If anyone could point me in the right direction that would be amazing.

Thanks.

like image 896
faooful Avatar asked Feb 20 '14 18:02

faooful


People also ask

How do I make a horizontal timeline in CSS?

By setting margin: auto the timeline will be horizontally centered. Tip: Make sure to set position: relative for parent elements and position: absolute for child elements so that the child elements can be properly arranged relative to their parent.

What is a horizontal timeline?

Horizontal timeline One of the most common types of timelines is a horizontal timeline, which tracks events from left to right. Usually these present information in sequential order, with the oldest event on the left and the most recent one on the right. The chronological timeline is one type of horizontal timeline.

Is a timeline vertical or horizontal?

Timelines have always been horizontal. The horizontal time axes in all graphs made in sciences, history, geography, reaffirms its lineage.


1 Answers

I literally JUST had to make one of these. This is what I came up with:

body {
  padding: 25px;
  font-family: sans-serif;
}

.timeline {
  white-space: nowrap;
  overflow-x: scroll;
  padding: 30px 0 10px 0;
  position: relative;
}

.entry {
  display: inline-block;
  vertical-align: top;
  background: #13519C;
  color: #fff;
  padding: 10px;
  font-size: 12px;
  text-align: center;
  position: relative;
  border-top: 4px solid #06182E;
  border-radius: 3px;
  min-width: 200px;
  max-width: 500px;
}

.entry img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-bottom: 10px;
}

.entry:after {
  content: '';
  display: block;
  background: #eee;
  width: 7px;
  height: 7px;
  border-radius: 6px;
  border: 3px solid #06182E;
  position: absolute;
  left: 50%;
  top: -30px;
  margin-left: -6px;
}

.entry:before {
  content: '';
  display: block;
  background: #06182E;
  width: 5px;
  height: 20px;
  position: absolute;
  left: 50%;
  top: -20px;
  margin-left: -2px;
}

.entry h1 {
  color: #fff;
  font-size: 18px;
  font-family: Georgia, serif;
  font-weight: bold;
  margin-bottom: 10px;
}

.entry h2 {
  letter-spacing: .2em;
  margin-bottom: 10px;
  font-size: 14px;
}

.bar {
  height: 4px;
  background: #eee;
  width: 100%;
  position: relative;
  top: 13px;
  left: 0;
}
<div class="bar"></div>
<div class="timeline">
  <div class="entry">
    <h1>1990</h1>
    <h2>Entry Title</h2>
    <img src="http://dummyimage.com/300x200/000/fff" /> Here's the info about this date
  </div>
  <div class="entry">
    <h1>1995</h1>
    Here's the info about this date
  </div>
  <div class="entry">
    <h1>2000</h1>
    Here's the info about this date
  </div>
  <div class="entry">
    <h1>2005</h1>
    Here's the info about this date
  </div>
  <div class="entry">
    <h1>2010</h1>
    Here's the info about this date
  </div>
</div>
like image 96
kthornbloom Avatar answered Nov 06 '22 01:11

kthornbloom