HTML/CSS How to Create a CSS Hover Effect That Displays Text?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Hovering Text
Click For Summary
To create a hover effect that displays text over images in a grid layout, implement a "card with a slide-up caption" using CSS. The grid is structured with a class called "grid-container" that utilizes CSS Grid for layout, allowing for responsive design with defined gaps between items. To achieve the hover effect, include the text in the HTML source code and apply a CSS class that triggers a transition on hover. This can be accomplished by using the :hover pseudo-class to change the visibility or position of the text. Additionally, libraries like Wow.js and animate.css can simplify the implementation of these effects. For browsers like Firefox and Chrome, developers can inspect elements and toggle pseudo-classes to see the effects in real-time, aiding in the design process.
shivajikobardan
Messages
637
Reaction score
54
TL;DR
How do I build component that shows some text when I hover over it?
https://practice-project-html-css.vercel.app/
1668930345844.png

I'm talking about this one.
When you hover there, it shows some text. How do I make it?
HTML:
 <div class="grid-container">
        <div class="one"><img src="project1.png" alt="" /></div>
        <div class="two"><img src="Project2.png" alt="" /></div>
        <div class="three"><img src="project3.png" alt="" /></div>
        <div class="four"><img src="project4.png" alt="" /></div>
        <div class="five"><img src="project5.png" alt="" /></div>
        <div class="six"><img src="project6.png" alt="" /></div>
        <div class="seven"><img src="project7.png" alt="" /></div>
        <div class="eight"><img src="project8.png" alt="" /></div>
        <div class="nine"><img src="project9.png" alt="" /></div>
      </div>

CSS:
.grid-container{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:40px;
  
}

Please tell me how to implement this feature.
 
Technology news on Phys.org
This is known as a "card with a slide-up caption" or more simply a "CSS hover effect". You can search for this.
 
You can give the image an alt text or title text or both, usually the same text, as some browsers display the alt text and others display the title text on hover, with no programming required by you to make it happen.

But the example you give is a css hover effect, which is shown in the source code. The text is there in the source code, and on hover it uses a class (in the html) and a transition (in the css) to slide it up.

There are useful libraries of effects such as Wow.js and animate.css that make life easier for you. Animate.css is called in the header of the sample page.
 
Last edited:
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K