Creating a hovered with CSS

In this tutorial we'll look at how to create an overlay easily using CSS!
•
Updated on August 14, 2026
•
2 min read
Believemy logo

In this first article in the history of BELIEVEMY, let's see together how to create a hovered effect: text that appears when you hover your mouse over an image!

You can find the entire tutorial on our Instagram account

 

Step 1

In this first step, we will start by displaying an image:

HTML
<img src="logo-believemy.png" alt="Logo" />

 

Step 2

Crop and wrap the image in a div:

HTML
<div class="container">
    <!-- Image -->
    <img src="logo-believemy.png" alt="Logo" />
</div>

And on the CSS side:

CSS
.container {
    position: relative;
    width: 500px;
}
.container img {
    width: 100%;
}

 

Step 3

Add the text to display:

HTML
<div class="container">
    <!-- Image -->
    <img src="logo-believemy.png" alt="Logo" />
    
    <!-- Text to display -->
    <div class="hovered">Hello World!</div>
</div>

And on the CSS side:

CSS
.hovered {
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    height: 100%; width: 100%;
    opacity: 0; transition: all .3s;
    background-color: #3f3f44;   
}

Here, we set the overlay to absolute position to place it correctly and initially hide it by setting its opacity to 0.

The top, bottom, left, and right properties make it take up the entire space.

 

Step 4

Make the overlay appear when the mouse hovers over the image, and do all this using only CSS.

CSS
.container:hover .hovered {
    opacity: 1;
}

When the mouse hovers over the container class (thus over the image), we set the opacity of our overlay class to 1 to display its content.

 

Step 5

Center the text of the overlay by wrapping the text in a span tag to better select it with CSS.

HTML
<div class="container">
    <!-- Image -->
    <img src="logo-believemy.png" alt="Logo" />
    
    <!-- Text to display -->
    <div class="hovered">
        <span>Hello World!</span>
    </div>
</div>

Finally, we select the span tag within the overlay class and center everything!

CSS
.hovered span {
    color: white;
    font-size: 5rem;
    position: absolute;
    top: 50%;
    left: 50%;
    font-family: arial;
    -webkit-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}

And here we are with a superb hovered effect!

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 an animated list with CSS

Let's find out how to create an animated hover list!

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 a very modern hover on a link

Here's an easy way to create a very modern hover on a link! There are lots of possible effects for buttons and links: the better they look, the more likely your users will be to click on them.

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 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

Create a glitch effect on mouse-over with CSS

Add a modern glitch effect to your presentations or your logo, whether it's hovering or permanent! Let's find out how.

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

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

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.