Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
How to make a vertical wavy text line using HTML and CSS ?
Next article icon

How to Make Responsive Vertical Timeline Design using only HTML and CSS ?

Last Updated : 26 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A Timeline is a list of events according to the order of dates which is used to get an overview of various tasks and their expected timing. Crafting a responsive vertical timeline design using only HTML and CSS involves making a visually pleasing layout that arranges content chronologically in a vertical manner. To make it responsive for small devices using media queries. This design improves user experience by showing information in a clear and easy-to-follow way and also ensures it looks good on different screen sizes.

Output Preview: Let us have a look at how the final output will look like.

timeline1
Preview

Approach

  • Firstly, create the main container containing each card with its respective image in the HTML file.
  • Position the container at the center with the appropriate width. Also, position the line to the center with the appropriate height.
  • Separate the cards in the left and right part of the line using left and right properties in the left and right class names of the respective cards.
  • Move the image to the center of the line and create the card arrow using the ::after selector.
  • The ':root' defines CSS variables that can be used throughout the stylesheet.
  • For responsiveness use media queries to move the cards in the vertical order to the right of the line. The '@media screen and (max-width:790px)' defines styles for smaller screens using media queries, ensuring the layout remains responsive and readable on different devices.

Example: Create an HTML file named index.html and a CSS file named style.css and paste the following code.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Responsive Vertical Timeline Design</title>     <link rel="stylesheet" href="style.css"> </head>  <body>     <header>         <h1>Geeks for Geeks</h1>         <p>Make Responsive Vertical Timeline Design using only HTML and CSS</p>     </header>     <main>         <div class="main-container">             <div class="line">                 <a href="#">Top</a>             </div>             <div class="card left">                 <h1>Oct 2023</h1>                 <p>React Tutorial: This free React tutorial is designed for people who prefer to learn by doing.</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="React Tutorial Image">                 </div>             </div>             <div class="card right">                 <h1>Nov 2023</h1>                 <p>React is one of the most popular, efficient, and powerful open-source JavaScript libraries for building dynamic and interactive user interfaces.</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="React Image">                 </div>             </div>             <div class="card left">                 <h1>Dec 2023</h1>                 <p>ReactJS is famous for its component-based architecture and virtual DOM which makes it highly efficient in rendering user interface and ensuring optimal performance.</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="ReactJS Image">                 </div>             </div>             <div class="card right">                 <h1>Jan 2024</h1>                 <p>It is very helpful in the efficient development and maintenance of large-scale applications.</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="React Development Image">                 </div>             </div>             <div class="card left">                 <h1>Feb 2024</h1>                 <p>Here are the ReactJS important topics that come under in this tutorial.</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="ReactJS Topics Image">                 </div>             </div>             <div class="card right">                 <h1>Mar 2024</h1>                 <p>A Project will always help you to be confident in your learning path, so we recommend you to follow the below-mentioned articles after you clear your fundamentals of React in our React Basics section</p>                 <div class="thumbnail">                     <img src="https://media.geeksforgeeks.org/wp-content/uploads/20240218121513/gfg2.jpg" alt="React Project Image">                 </div>             </div>         </div>     </main> </body>  </html> 
CSS
:root {     scroll-behavior: smooth; }  * {     margin: 0;     padding: 0;     box-sizing: border-box; }  body {     display: flex;     flex-direction: column;     justify-content: center;     align-items: center;     background-color: rgb(170, 230, 189); }  header {     display: flex;     flex-direction: column;     align-items: center;     row-gap: 20px;     margin-top: 10px; }  header h1 {     background-color: #fff;     padding: .2em .5em;     border-radius: 1em;     color: green;     font-size: 1.5rem; }  header p {     font-size: 1.25rem; }  .main-container {     margin-top: 20px;     width: 800px;     display: flex;     flex-direction: column;     align-items: center; }  .line {     position: absolute;     left: 50%;     height: 1000px;     width: 10px;     display: flex;     align-items: center;     justify-content: center;     border-radius: 100px;     transform: translateX(-50%);     background-color: blue; }  .line a {     text-decoration: none;     display: flex;     align-items: center;     justify-content: center;     position: absolute;     bottom: 0;     width: 50px;     height: 50px;     font-weight: bold;     color: rgb(55, 131, 65);     background-color: #fff;     border-radius: 50%;     cursor: pointer;     overflow: hidden; }  .card {     font-size: .8rem;     width: 200px;     height: 150px;     border-radius: 10px;     background-color: white;     margin-bottom: 10px; }  .left {     position: relative;     left: -150px; }  .right {     position: relative;     left: 150px; }  .left::after, .right::after {     content: '';     position: absolute;     width: 35px;     height: 35px;     background-color: rgb(18, 113, 48);     border-radius: 0px 10px;     transform: rotate(-45deg);     z-index: -1; }  .left::after {     top: 5px;     right: -10px; }  .right::after {     top: 5px;     left: -10px; }  .card h1 {     padding: 5px;     display: flex;     justify-content: center;     border-radius: 10px 10px 0 0;     color: white;     background-color: rgb(18, 113, 48); }  .card p {     padding: 10px; }  .thumbnail {     position: absolute;     top: 0;     width: 50px;     height: 50px;     border-radius: 50%;     overflow: hidden; }  .thumbnail img {     width: 100%;     height: 100%; }  .left .thumbnail {     left: 113%; }  .right .thumbnail {     right: 225px; }  @media screen and (max-width:790px) {     body {         text-align: center;         padding: 0 10px;     }      .main-container {         width: auto;     }      .line {         height: 1550px;     }      .card {         top: 70px;         margin-bottom: 100px;     }      .left::after,     .right::after {         visibility: hidden;     }      .left {         left: auto;     }      .right {         left: auto;     }      .left .thumbnail {         top: -70px;         left: 75px;     }      .right .thumbnail {         top: -70px;         left: 75px;     } } 

Output:


Next Article
How to make a vertical wavy text line using HTML and CSS ?

R

rohan_paul
Improve
Article Tags :
  • Web Technologies
  • Web Templates

Similar Reads

  • How to make a HTML div responsive using CSS ?
    The CSS Media Query can be used to make an HTML "div" responsive. The media queries allow the users to change or customize the web pages for many devices like desktops, mobile phones, tablets, etc without changing the markups. Using the media query, the user can change the style of a particular elem
    2 min read
  • How to design Meet the Team Page using HTML and CSS ?
    You will learn how to create a simple and responsive “Meet the Team” page using HTML and CSS. We will use HTML to structure the content of the page, such as the headings, paragraphs, images, and links, and then we use CSS to style the elements of the page, such as the colors, fonts, and layout. Here
    5 min read
  • How to make a vertical wavy text line using HTML and CSS ?
    In this article, a wavy animated text is implemented using HTML and CSS. It is one of the simplest CSS effects. For a beginner, it is one of the best examples to learn the concept of CSS pseudo-elements. Approach: The basic idea of getting wavy texts is performed by using the combination of some CSS
    2 min read
  • How to create Vertical Menu using HTML and CSS ?
    In This article, we will learn how to create vertical menus by using HTML and CSS. Vertical Menu: We can create a vertical menu in the form of buttons and a scrollable menu. Vertical Menu is the buttons arranged in the vertical menu bar/navbar. How to create a vertical menu using buttons: We can cre
    2 min read
  • How to design a responsive Web Page in HTML ?
    In this article, we will learn how to design a responsive Web Page in HTML. Responsive web design (RWD) is a web development approach that creates dynamic changes to the appearance of a website, depending on the screen size and orientation of the device being used to view it. RWD can be obtained by
    3 min read
  • How to Create Responsive Sidebar using HTML & CSS ?
    Creating a responsive sidebar using HTML and CSS means designing a navigation menu that adapts seamlessly to different screen sizes. It provides a user-friendly experience on both desktop and mobile devices, adjusting its layout for better readability and easy access to content. ApproachBasic Struct
    2 min read
  • How to create Vertical Navigation Bar using HTML and CSS ?
    After reading this article, you will be able to build your own vertical navigation bar. To follow this article you only need some basic understanding of HTML and CSS. Let us start writing our vertical navigation bar, first, we will write the structure of the navigation bar. In this tutorial, we crea
    3 min read
  • How to create Responsive Profile Card using HTML and CSS ?
    In this article, we are going to create a profile card from where a user can check out the basic details of other users and connect with them through different handles as well as message the user. Approach:Set up HTML with a container div containing an image and content sections.Style the container,
    5 min read
  • How to Align Social Media Icons Vertically on Left Side using HTML CSS & JavaScript?
    In this article, we will learn how to create vertically aligned social media icons on the left side of a webpage using HTML, CSS, and JavaScript. We will use HTML to create the basic structure, CSS for styling, and JavaScript for added functionality. PrerequisitesHTMLCSSJavaScriptApproachWe are usin
    4 min read
  • Periodic Table Design using HTML and CSS
    This article will show you how to create a Periodic Table design using HTML, and CSS. The Periodic Table is a tabular arrangement of chemical elements, where they are organized by their atomic number, electron configuration, and recurring chemical properties. It provides a systematic way to understa
    10 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences