Creating an animated list with CSS

Let's find out how to create an animated hover list!
•
Updated on August 14, 2026
•
2 min read
Believemy logo

Let's discover together how to create an animated list on hover!

Image

 

Step 1

Let's handle the HTML.

HTML
<ol>
  <li>HTML</li>
  <li>JavaScript</li>
  <li>Sass</li>
  <li>Bootstrap</li>
</ol>

We just need a list! (Astonishing, isn't it?)

 

Step 2

Let's move on to the CSS and style the list.

CSS
ol {
    width: 300px;
    list-style: none;
}

ol li {
    font-size: 1.2rem;
    padding: 20px 30px;
    margin: 10px 0;
    background: rgb(23, 23, 23);
    z-index: 5;
    position: relative;
    cursor: pointer;
    transition: all .4s;
}

We give our list a simple look: it has no bullets and we ensure that each list item is wrapped in a full block with margins and a background.
The z-index: 5 will allow us in the next step to overlay the small border on the left side relative to the text, without it covering the entire item on hover (it is actually a pseudo-element ::before).

 

Step 3

Let's now style the border.

CSS
ol li::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    z-index: -1;
    transition: all .4s;
}

ol li:hover::before {
    width: 100%;
}

This allows us to define a different colored shadow for each list element.

 

Step 4

Let's define a different color for each list item.

CSS
ol li:nth-child(1)::before {
    background: #4285f4;
}

ol li:nth-child(2)::before {
    background: #db4437;
}

ol li:nth-child(3)::before {
    background: #f4b400;
}

ol li:nth-child(4)::before {
    background: #0f9d58;
}

 

Step 5

Let's shift the list element when it is hovered over.

CSS
ol li:hover {
    transform: translateX(20px);
}
Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

Creating a hovered with CSS

In this tutorial we'll look at how to create an overlay easily using CSS!

December 9, 2024

Create a map displaying links on mouse-over with CSS

To present your team or simply yourself, this animation will allow you to display the links to your social networks when you hover over the map: a striking effect guaranteed! Let's find out how to do it together.

December 9, 2024

Creating animated presentation cards with JavaScript

Whether you're presenting the team behind your project or anything else, using animated presentation cards will give your page a successful finishing touch. Find out how in this article!

December 9, 2024

Creating a cascading animation on text

For a slogan or for an animation on a very important page of your project, this very modern effect is also very easy to achieve. Let's take a look at how to do it in this article.

December 9, 2024

Create hover text on image with CSS

We've already seen how to create an element that is displayed when the mouse hovers over an image, but in this article we'll show you how to display a whole host of information very fluidly by hovering the mouse over an element!

December 9, 2024

Create an animated gradient background on hover avec CSS

Whether it's to highlight a part of your website or a quote as in this example, generating and adding a gradient to the background can give your website a very modern touch. Find out in this article how to do it easily!

December 9, 2024

Creating circled buttons on hover with HTML and CSS

For a menu or to encourage your readers to share your website, share buttons are essential elements to add to your website. Let's find out how to make them more modern with a "neon" effect that will surround the icon selected by your user.

December 9, 2024

Create an animated "rainbow" button with CSS

In this article, we'll show you how to create a rainbow button that comes to life when the mouse hovers over it. A modern and sensational effect guaranteed!

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.