CSS Horizontal Timeline Design

https://i.sstatic.net/zBXre.png

Looking for an image like this one, with horizontal scrolling navigation buttons to dynamically update the list. I have included CSS and HTML code below. The task should be accomplished using only CSS, but JavaScript can be used for the navigation icons. Additionally, the text within the <li> elements should not overlap even if it is lengthy.

.timeline {
  white-space: nowrap;
  overflow-x: hidden;
}

.timeline ol {
  font-size: 0;
  width: 100vw;
  padding: 250px 0;
  transition: all 1s;
}

.timeline ol li {
  position: relative;
  display: inline-block;
  list-style-type: none;
  width: 160px;
  height: 3px;
  background: #e1e2e3;
}

.timeline ol li:last-child {
  width: 280px;
}

.timeline ol li:not(:first-child) {
  margin-left: 14px;
}

.timeline ol li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  bottom: 0;
  width: 12px;
  height: 12px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #e1e2e3;
}
<div class="timeline">
    <ol>
      <li>abc</li>
      <li>hello welcome</li>
      <li>cool summer</li>
      <li>hi there</li>
      <li>whats up</li>
    </ol>
</div>

Answer №1

Check out this CSS code for creating a timeline:

.timeline {
  overflow-x: hidden;
  padding: 20px 0;
}

.timeline ol {
  width: 100%;
  transition: all 1s;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
}

.timeline ol li {
  list-style: none;
  position: relative;
  text-align: center;
  flex-grow: 1;
  flex-basis: 0;
  padding: 0 5px;
}

.timeline ol li:before {
  content: "";
  width: 10px;
  height: 10px;
  display: block;
  border-radius: 50%;
  background: #ccc;
  margin: 0 auto 5px auto;
}
.timeline ol li:not(:last-child)::after {
    content: "";
    width: calc(100% - 14px);
    height: 2px;
    display: block;
    background: #ccc;
    margin: 0;
    position: absolute;
    top: 4px;
    left: calc(50% + 7px);
}

Click here to view the code in action on JSFiddle

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Horizontal scrollbar displayed by CSS Bootstrap

Experimenting with Bootstrap on a small project and encountering an issue that I can't seem to figure out. Here is the snippet of my code: nav{ background-color: lightblue; } section{ background-color: lightgreen; } <link href="http://netd ...

Customize the appearance of HTML5 input types when validation is unsuccessful

Hey everyone I have a question: Is there a CSS trick to style the red border (or shadow) of input fields that have not been validated, such as email inputs? If my explanation isn't clear enough, I'm referring to changing the color of this eleme ...

The AngularJS $http.post method mimicking a successful $.ajax request is causing a 401 UNAUTHORISED error

I have been working on rewriting a functional $.ajax server call to utilize AngularJS $http.put. However, the $http method returns a 401 unauthorized error. The original ajax call I am attempting to rewrite is structured like this: $.ajax({ url: domain ...

What is the correct way to transfer a function from a component.ts file to a service file?

I recently wrote a function in my component.ts file that sends a PUT request. It was working perfectly fine, but I decided to refactor and move the function to a service.ts file. After moving it, the functionality seems to have broken. Whenever I click on ...

Issue with Bootstrap card "sub-components" such as card-heading not functioning

I'm facing an issue while trying to integrate BlazorStrap into an existing .NET6 Blazor web assembly app. It seems like there is a problem with Bootstrap that needs to be resolved before I can get BlazorStrap to function properly. Let's focus on ...

Adjusting the width of an element by modifying its border-collapse property

Is there a way to implement "border-collapse: collapse" without affecting the width of the element? The Issue: Without using the border-collapse property, the right and left borders appear bold because they are adjacent. Using the border-collapse propert ...

Sorry, the value of pos[i] is currently unknown and cannot be

Looking at this specific array structure: T1 = [ { tipo:"m", pos: [ [0,0] ] },{ tipo:"b", pos: [ [0,0.223,0.1,0.5,0.11,0.5] ] }, { tipo:"m", pos: [ [0,0] ] } ] My goal is to ...

Having trouble getting a dropdown menu to function properly with jQuery

Within my project, I have implemented a menu that transforms into a dropdown menu for smaller screens. Below is the HTML code for this functionality: <select> <option value="index.php" id="home">Home</option> <option value="about ...

Retrieve detailed Paypal donation transaction information in HTML format with the donation button functionality integrated

I'm currently in the process of building a web application for a non-profit organization, which includes a Paypal Donation feature. I am using HTML5, CSS3, and jQuery to develop this application. I have successfully implemented the Donation button fro ...

Jorn's JQuery Tooltip Plugin - A Must-Have for Interactive Websites

Has anyone come across this issue before? I am attempting to create a tooltip that displays the input [type=text] value when rolled over, using a plugin available at http://bassitance.de. However, I need to use titles and classes for validation on specific ...

What is the best way to replace "NaN" with a blank space within an array?

How can I replace "NaN" with a space in an array? let numbers = [1, 2, 3, NaN]; let result = numbers.map(num => isNaN(num) ? " " : num); console.log(result); I would like the output to be [1, 2, 3, " "] ...

ReactJS Component Alignment Guide

I am currently learning React and facing difficulty in aligning a component to a specific position. import React from "react"; import "./styles.css"; import { Typography, Container, Grid, Button } from "@material-ui/core"; imp ...

Laravel project is experiencing issues with Ajax calls

I am facing an issue in my Laravel project where I have multiple checkboxes on a page. Upon checking each checkbox, I need to send the corresponding IDs to the Laravel controller. However, I keep encountering an error. Below is the AJAX code snippet: ...

Remove all event bindings using jQuery's one() method

Currently, I am utilizing JQuery's .one() function to check for any interaction. var myEvents = 'mousedown mousemove mouseup touchstart touchmove touchend mouseout'; jQuery(document).one(myEvents, function(){ //perform an a ...

Unable to eliminate the default styling of Material UI table using an external CSS file

Currently, I am incorporating a Material Ui table into my project. My goal is to eliminate the border and adjust the padding of the table. Upon investigation, I came across a default className for material ui table known as MuiTableCell-root-40. Below is t ...

Issue with Mongoose $in operator causing updates to only affect a single document

Having some issues with the "$in" operator in Mongoose. I have a User schema that includes an array of Card schema. The Card schema contains a 'score' field that I want to update based on a list of Card ids. Here's what I have attempted: Us ...

Utilizing ReactJS and TypeScript to retrieve a random value from an array

I have created a project similar to a "ToDo" list, but instead of tasks, it's a list of names. I can input a name and add it to the array, as well as delete each item. Now, I want to implement a button that randomly selects one of the names in the ar ...

Inspect the table and format the tr content in bold depending on the values found in two corresponding columns within the same table

Looking to create a responsive table where row content becomes bold if it matches the current date. Hiding the first-child th & td as they are only needed for a specific function. Comparing values in <td data-label="TodaysDate">06-05-2020</t ...

The script fails to work correctly when displaying the data

Last night, I finally cracked the code on how to transfer data from my form on the index page to the content page, and then display the results inside the content div back on the index page. However, a new challenge has emerged. My Javascript function (re ...

Locate and substitute text, language equivalency

I'm encountering issues with finding and replacing words in PHP files, especially when dealing with a large number of them. I'm considering using javascript/jQuery as an alternative solution. I want to create a table mapping word_to_replace to ne ...