Adjusting Bootstrap card content on hover

Currently, I am in the process of developing a website that features a list of products presented in bootstrap cards. I am seeking advice on how to dynamically change the text displayed on these cards when a user hovers over them. Specifically, I want to replace or hide the original text with completely different content. If anyone has any suggestions, elegant solutions, or pointers to help me achieve this effect, I would greatly appreciate it. Thank you!

Answer №1

You have the option to create 2 separate divs for displaying text and text hover, and toggle the display property based on card hover events.

.card-hover-text{
    display:none;
}
.card:hover .card-text{
    display:none;
}
.card:hover .card-hover-text{
    display:block;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="197b76766d6a6d6b7869592c3728372a">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">

<div class="card" style="width: 18rem;">
  <img class="card-img-top" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%22286%22%20height%3D%22180%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20286%20180%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_180284fd0bb%20text%20%7B%20fill%3Argba(255%2C255%2C255%2C.75)%3Bfont-weight%3Anormal%3Bfont-family%3AHelvetica%2C%20monospace%3Bfont-size%3A14pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_180284fd0bb%22%3E%3Crect%20width%3D%22286%22%20height%3D%22180%22%20fill%3D%22%23777%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%22107.1953125%22%20y%3D%2296.3%22%3E286x180%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" alt="Card image cap">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <p class="card-hover-text">New text</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>

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

Changing a file object into an image object in AngularJS

Can a file object be converted to an image object? I am in need of the width and height from the file (which is an image). Here is my code: view: <button id="image_file" class="md-button md-raised md-primary" type="file" ngf-select="uploadFile($file ...

Add the element to a fresh array only if there are no duplicate values present

I am faced with a challenge involving an array of names where duplicate entries, such as "Kenny," are causing some confusion. I only want each name to be included in the new array once, but I'm struggling to achieve this. Here's my progress so fa ...

Issue with EJS template displaying no information

I am encountering an issue with ejs templates. While I have successfully used it in a previous project, in my current one, it's not working as intended. Instead of rendering the cards with the passed data, all I see is a blank page. Here is my code fo ...

Challenges arising from utilizing distinct list style types for both parent and child elements with the assistance of CSS List

I am experimenting with the CSS counter reset feature to create a numbering system on my website. The main list should be in regular decimal format (e.g. 1, 2, 3, 4) while the sub-list should be in upper Roman numerals (e.g. I, II, III, IV, etc). Below is ...

Encountering a NULL argument in an MVC controller when executing an Ajax post request

I am facing an issue with my ajax post request where I send JSON string data, but it is showing null in my controller. Here is the AJAX Call: var jsonData = JSON.stringify(matrixPresenter); $.post("/matrix/Savematrix?matrixData=" + jsonData , fu ...

What is the process of securing a directory with a password using Node.js and Express?

I am in the process of creating a basic web server using Node.js and Express. My aim is to host various static files, one of which includes a Unity WebGL game. In order for the game to function properly, numerous assets need to be loaded. I am interested ...

Incorporate descriptive text to my HTML slider

How do I customize my carousel to display unique titles or captions for each slide? Here is the code snippet provided: <h1>Incredibly Basic Slider</h1> <div id="slider"> <a href="#" class="control_next">>></a> < ...

How to encase HTML content within a scope variable without relying on ng-bind-html

Is there a way to include HTML content using a scope variable in AngularJS without utilizing ng-bind-html-unsafe? <div ng-controller="dataController">{{test}}</div> $scope.test = "<div>Html content</div>" ...

jQuery struggling to parse HTML retrieved through AJAX call

While working on parsing some XML data received from an AJAX request, I encountered a special case that required additional handling. Occasionally, the server would return HTML content, prompting the need for a page reload. However, when attempting to iden ...

Sails encountering CORS preflight error due to cross-origin request

I am new to creating hybrid apps and have been following some tutorials. However, I encountered these errors on my browser console: Refused to load the script 'http://192.168.1.142:35729/livereload.js?snipver=1' due to Content Security Policy di ...

Ensure that the <TabPanel> content occupies the entire width and height of its parent container

Currently, I am working with React and material-ui. Specifically, I am utilizing an appbar with tabs and my goal is to have the content of each tab expand to full width and height when selected. If you'd like to see an example, check out this sandbox ...

How to dynamically apply the orderBy filter in AngularJS

Attempting to input ordering criteria from a text box and dynamically order the content. The current code is functioning properly, but when attempting to change: orderBy:'age' to orderBy:'{{criteria}}' the functionality breaks. Her ...

What are some strategies for optimizing Next.js applications for mobile devices?

https://i.stack.imgur.com/mWmWG.png After realizing that the structure of my Next.js app doesn't align with Create React App's folder system, I'm stuck on how to effectively scale my website for mobile devices. In my confusion, I'm una ...

Making an Ajax request to trigger a method within a controller

Here is the code snippet I wrote: $(function () { $("input#Submit1").on('click', function () { $.ajax({ url: 'Home/GetPort', method: 'GET' }); alert("test") ...

In a React component, what is the significance of "this" in relation to accessing state values (this.state...)?

I encountered a challenging issue with the usage of the this keyword while setting a state within an ajax call. It seems like I may have misunderstood something about how React components operate. How should I properly utilize the this keyword in this sp ...

What is the best way to make sure the background color of a container stretches across the full width of the screen?

I am currently learning HTML and CSS, and as a practice project, I am working on building a portfolio webpage. In the image provided, there are two containers, and I am facing an issue with the space on the sides when changing the background color. Despite ...

Tutorial: Implementing InfoWindows for Markers in Google Maps API V3 in a C# Web Page

Here's my newbie question, hope the formatting is correct :) I'm working on an ASP.NET, C# application that retrieves coordinates (Lat, Lon) from SQL and displays them as markers (which is working fine). However, when I try to add infowindow ...

Having trouble with TypeScript Library/SDK after installing my custom package, as the types are not being recognized

I have created my own typescript library using the typescript-starter tool found at . Here is how I structured the types folder: https://i.stack.imgur.com/igAuj.png After installing this package, I attempted a function or service call as depicted in the ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

PHP and AJAX concurrent session issue causing difficulties specifically in Chrome browser

TL;DR. I'm encountering an issue in Chrome where different requests are seeing the same value while incrementing a session counter, despite it working fine in Firefox and Internet Explorer. I am attempting to hit a web page multiple times until I rec ...