Tips for utilizing the stretched-link bootstrap class while maintaining the :hover effect directly on the card

I recently customized a bootstrap product card to allow users to access the product details either by clicking on the card itself or by clicking on the product name. To achieve this, I utilized Bootstrap's stretched-link class. However, an issue arose where all of the :hover behaviors on different elements within the card were lost.

This is how my card looks like:

<div class="col mb-4">
    <div class="product-card">
        <img src="../asset/images/golden-chain-purse.jpg" class="card-img-top product-img" alt="...">
        <p class="product-price">{{ product.price }}
            €
        </p>
        <a class="etsy-button" href="{{ product.etsyLink }}" target="_blank">Buy on Etsy &copy</a>
        <a class="product-details-link stretched-link" href="{{ path('product_details', {product_id: product.id }) }}"></a>
    </div>
    <a class="product-details-link" href="{{ path('product_details', {product_id: product.id }) }}">
        <h5 class="card-title">{{ product.name }}</h5>
    </a>
</div>

Here are the CSS styles for the hover effects on my card:

.product-card:hover img {
    filter: blur(3px);
}

.product-card:hover :not(img) {
    opacity: 1;
    transition: .5s;
}

.etsy-button:hover {
    background-color: rgba(238, 182, 191, 0.637);
    padding: 0.4em 0.6em;
    text-decoration: none;
    margin-top: 0.3em;
}

.product-details-link:hover {
    text-decoration: none;
}

Answer №1

One common issue that arises is related to the z-index. You can address this problem by implementing the following CSS:

.<that_class_that_not_show_your_hover> {
    z-index: 2;
    position: relative;
}

FOR INSTANCE

.etsy-button {
    z-index: 2;
    position: relative;
}

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<style>
  .product-card:hover img {
    filter: blur(3px);
  }
  
  .product-card:hover :not(img) {
    opacity: 1;
    transition: .5s;
  }
  
  .etsy-button:hover {
    background-color: rgba(238, 182, 191, 0.637);
    padding: 0.4em 0.6em;
    text-decoration: none;
    margin-top: 0.3em;
  }
  
  .product-details-link:hover {
    text-decoration: none;
  }
  
  .etsy-button {
    z-index: 2;
    position: relative;
  }
</style>


<div class="col mb-4">
  <div class="product-card">
    <img src="https://i.picsum.photos/id/381/200/300.jpg" class="card-img-top product-img" alt="...">
    <p class="product-price">{{ product.price }} €
    </p>
    <a class="etsy-button" href="https://stackoverflow.com" target="_blank">Buy on Etsy &copy</a>
    <a class="product-details-link stretched-link" href="https://google.com"></a>
  </div>
  <a class="product-details-link" href="{{ path('product_details', {product_id: product.id }) }}">
    <h5 class="card-title">{{ product.name }}</h5>
  </a>
</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

Add two columns for mobile devices in the Woocommerce platform

How can I display 2 columns of products in my Woocommerce shop using a child theme based on 'Shopisle'? Is a CSS-only solution the best approach for this task, and will it work smoothly without any bugs? I suspect that the theme is built on Boot ...

Displaying text within an HTML table featuring a vibrant background

I'm having trouble printing a basic certificate that is formatted as an HTML table. There are a couple of frustrating issues I'm facing. 1) When I try to print the table using Chrome, my CSS changes are not being applied. 2) I can't seem to ...

Switching the displayed image depending on the JSON data received

As a beginner in javascript and jQuery, I am working on displaying JSON results in the browser. My goal is to generate dynamic HTML by incorporating the JSON data. Below is an example of the JSON structure: [{"JobName":"JobDoSomething","JobStatus":2,"JobS ...

Creating a Visual Presentation with Background Image Transition in HTML, CSS, and JavaScript

Seeking assistance in setting up a basic background image slideshow on my website. I have been unable to locate a suitable tutorial online, so I'm reaching out here for guidance. HTML: <body> <h3>Welcome!</h1> <p>Lorem i ...

Is there a way to align my horizontal menu with the top of the screen without encountering the hover problem?

I'm trying to make my horizontal navigation bar stay at the top of the screen. The issue is that when I set the top property to 0, the menu sticks to the top but the initial menu item is obscured when hovered over. If I remove the top property, the ho ...

Retrieving Blocked Images with Selenium: A Step-by-Step Guide

HTML: <html> <head> <body onload="document.getElementById('a').style.display='block';"> <div id="a" align="center" onclick="document.location.reload();" style="display: block; cursor: pointer;"> <img width="9 ...

"Enhancing User Experience with Hover Effects in HTML using .common

I'm pretty new to coding and currently working on a Github repository. On the same page, I have 12 clickBoxes that each have a hover effect applied where a PNG appears upon hovering. However, I've run into an issue where either the hover effect w ...

The art of CSS layout and scrolling

I am attempting to create a layout with a fixed left menu and a fixed right banner that stay in place while the center panel scrolls text. The banner needs to be on top of the center panel due to its size, and the color scheme consists of white text on a b ...

Modify an HTML document using a PHP script

I am creating a website that automatically generates an HTML template with some customizable text through a form. However, I want the ability to retrieve that text in the form after pressing a button or taking some action, so it can be edited. I've ...

Toggling jQuery to show or hide content depending on the selector

I am looking to implement a jQuery-based animation and here is the code I have so far: >items=document.querySelectorAll("#customers td span"); [<span alt=​" 02,Counter,11,2013-04-06 14:​59:​16">​ 02​</span>​, <span>​11 ...

Guide on accessing elements such as inputs and selects in a changing form

I'm using a dynamic form that creates fields on the fly when the "+" button is clicked. This form isn't hardcoded into the document, but rather generated when the button is pressed. I'm wondering how I can access the form values. Should I ...

Guide to displaying options in the Vue material select box even when the default value is blank

I have implemented the material design framework vuematerial with vue.js. In traditional HTML, a selection box looks like this: <select> <option value="">You should initially see this</option> <option value="1">One</o ...

If a table column lacks an unspanned cell, IE will disregard its width

Here is a visual representation of the issue I am facing: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <body> <table border="1"> <colgroup> <col ...

Styling drop caps using CSS on Wordpress posts

I've successfully implemented a customized dropcap for my Wordpress blog posts using CSS. Is there a way to limit this effect to just the first paragraph, leaving subsequent paragraphs unaffected? Any guidance on achieving this would be highly apprec ...

Can anyone assist me with this HTML/jQuery code?

Despite my efforts, I've been unable to achieve success. The challenge I'm facing is with duplicating controls for adding images. I have a button and a div where the user can choose an image by clicking the button. The selected image appears in ...

Manage the selection of multiple items when clicking on and off a button or component

I am currently working on implementing a feature with multi-select buttons using a custom component. My goal is to require that at least one option is selected at all times. This means that users can select multiple options, but the last remaining option c ...

Combining AngularJS and Java to create dynamic web applications in HTML5 mode

I'm developing a platform that uses AngularJS for the frontend and Java with Jersey for the backend. However, I've encountered an issue when trying to eliminate the "#" from the URL using $locationProvider.html5Mode(true);. When I click on a li ...

Swapped out image hyperlink for a clickable button

As someone new to javascript, I'm encountering an issue with this code. I want to update my image links when a button is clicked in my code. However, the problem is that my image links are already being updated before I even click the button. Below ar ...

Scrolling automatically to a DIV is possible with jQuery, however, this feature is functional only on the initial

I'm currently working on a Quiz site and I've encountered a puzzling issue. Since the explanation only appears after an answer is selected - essentially a "hidden" element, I decided to wrap that explanation into a visible DIV. The code I'v ...

Securing a downloadable file with a password on a webpage

I am looking to create a webpage with a password-protected download option for a PDF. When someone clicks on the link, they should be prompted to enter a username and password. If they try to directly access the PDF at "www.example.com/~folder_name/abc.pdf ...