← Back toCSS layout

Timeline

Written byPhuoc Nguyen
Created
12 Dec, 2019
Category
Display

HTML

index.html
<div class="timeline">
<!-- Left vertical line -->
<div class="timeline__line"></div>

<!-- The timeline items timeline -->
<div class="timeline__items">
<!-- Each timeline item -->
<div class="timeline__item">
<!-- The circle and title -->
<div class="timeline__top">
<!-- The circle -->
<div class="timeline__circle"></div>

<!-- The title -->
<div class="timeline__title">...</div>
</div>

<!-- The description -->
<div class="timeline__desc">...</div>
</div>

<!-- Repeat other items -->
...
</div>
</div>

CSS

styles.css
.timeline {
/* Used to position the left vertical line */
position: relative;
}

.timeline__line {
/* Border */
border-right: 2px solid #d1d5db;

/* Positioned at the left */
left: 0.75rem;
position: absolute;
top: 0px;

/* Take full height */
height: 100%;
}

.timeline__items {
/* Reset styles */
list-style-type: none;
margin: 0px;
padding: 0px;
}

.timeline__item {
margin-bottom: 8px;
}

.timeline__top {
/* Center the content horizontally */
align-items: center;
display: flex;
}

.timeline__circle {
/* Rounded border */
background-color: #d1d5db;
border-radius: 9999px;

/* Size */
height: 1.5rem;
width: 1.5rem;
}

.timeline__title {
/* Take available width */
flex: 1;
margin-left: 0.5rem;
}

.timeline__desc {
/* Make it align with the title */
margin-left: 2rem;
}
If you found this post helpful, please consider giving the repository a star on GitHub or sharing the post on your favorite social networks 😍. Your support would mean a lot to me!

Questions? 🙋

Do you have any questions about front-end development? If so, feel free to create a new issue on GitHub using the button below. I'm happy to help with any topic you'd like to learn more about, even beyond what's covered in this post.
While I have a long list of upcoming topics, I'm always eager to prioritize your questions and ideas for future content. Let's learn and grow together! Sharing knowledge is the best way to elevate ourselves 🥷.
Ask me questions

Recent posts ⚡

Newsletter 🔔

If you're into front-end technologies and you want to see more of the content I'm creating, then you might want to consider subscribing to my newsletter.
By subscribing, you'll be the first to know about new articles, products, and exclusive promotions.
Don't worry, I won't spam you. And if you ever change your mind, you can unsubscribe at any time.
Phước Nguyễn