Display Content on hovering Card using CSS Last Updated : 24 Jul, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will see how we can create a card that displays content on hovering using the hover property using HTML and CSS.HTML Code: In this section, we will create the structure of our HTML card. Create a "div" with class name "card".Create another "div" inside the main "div" with class name "card__inner".Add heading "h2" and paragraph inside the second "div" with some random content. HTML <!DOCTYPE html> <html> <body> <!-- div with class which will act as a container for us --> <div class="card"> <!-- Content of card to be display on hovering --> <div class="card__inner"> <h2>GeeksforGeeks</h2> <p> A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and ... </p> </div> </div> </body> </html> CSS Code: In this section, we will assign general properties to the element using CSS. CSS /* Assigning general property to card */ .card { position: relative; width: 20rem; height: 30rem; background-size: cover; background-color: black; background-image: url('one.png'); border-radius: 20px; background-position: center; overflow: hidden; } /* Assigning properties to inner content of card */ .card__inner { background-color: rgba(0, 0, 0, 0.9); color: #fff; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; z-index: 1; opacity: 0; padding: 2rem 1.3rem 2rem 2rem; transition: all 0.4s ease 0s; } /* On hovering card opacity of content must be 1*/ .card:hover .card__inner { opacity: 1; } /* General property for heading and paragraph*/ .card__inner h2 { margin-top: 1rem; } .card__inner p { overflow-y: scroll; height: 87%; padding-right: 1rem; font-weight: 200; line-height: 2.5rem; margin-top: 1.5rem; } Complete Code: In this section, we will combined the above two sections of code. HTML <!DOCTYPE html> <html> <head> <style type="text/css"> /* Assigning general property to card */ .card { position: relative; width: 20rem; height: 30rem; background-size: cover; background-color: black; background-image: url('one.png'); border-radius: 20px; background-position: center; overflow: hidden; } /* Assigning properties to inner content of card */ .card__inner { background-color: rgba(0, 0, 0, 0.9); color: #fff; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; z-index: 1; opacity: 0; padding: 2rem 1.3rem 2rem 2rem; transition: all 0.4s ease 0s; } /* On hovering card opacity of content must be 1*/ .card:hover .card__inner { opacity: 1; } /* General property for heading and paragraph*/ .card__inner h2 { margin-top: 1rem; } .card__inner p { overflow-y: scroll; height: 87%; padding-right: 1rem; font-weight: 200; line-height: 2.5rem; margin-top: 1.5rem; } </style> </head> <body> <!-- div with class which will act as a container for us --> <div class="card"> <!-- Content of card to be display on hovering --> <div class="card__inner"> <h2>GeeksforGeeks</h2> <p> GeeksforGeeks: Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes etc. It contains many free and premium contents. GeeksforGeeks: Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes etc. It contains many free and premium contents. </p> </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article Display Content on hovering Card using CSS N NANDINIJAIN Follow Improve Article Tags : Web Technologies CSS CSS-Questions Similar Reads How to Display Element on Hover using CSS ? In web development, displaying an element on hover is a common interaction pattern used to reveal additional content or actions. Below are the various CSS approaches to achieve this effect: Table of Content Using the display propertyUsing the visibility propertyUsing the display propertyThis approac 2 min read Onsen UI Card CSS Components Onsen UI CSS is used to create beautiful HTML components. It is one of the most efficient ways to create HTML5 hybrid components that are compatible with both mobile and desktop. In this article, we are going to implement the Onsen UI Card CSS Components. A Card is an HTML component used to show dat 3 min read How to Create Image Hovered Detail using HTML & CSS? In this article, we will learn how to create a type of hover effect over an image to get its complete detail. This is can be achieved by using simple HTML & CSS.Overview Of Our Project:Approach:We will first create an HTML file in which we are going to add an image for our image hanger.We will t 3 min read Display div element on hovering over <a> tag using CSS We will render the div element by hovering over the <a> tag using CSS. We can apply an adjacent sibling CSS selector property to the <a> tag that will display the hidden div element's content while hovering over it. The Adjacent sibling selector is a CSS Combinators, used to select the e 2 min read How to Build a Card component using Tailwind CSS ? In this article, we will learn about how to Build a card component using Tailwind CSS, Tailwind CSS is a CSS framework that helps in building rapid custom UI. It is a highly customizable, low-level CSS framework that gives you all of the building blocks that you need. Tailwind CSS creates small util 4 min read Like