Encountering an issue with Javascript while hovering over an element in a grid layout

After multiple attempts, I am still unable to determine why the text only appears when hovering over the last two product-cards in this grid layout. The preceding two cards display the text only when hovering over a specific area within the card, and the ones before that do not show any text at all...

@font-face {
    font-family: 'Montserrat-Light';
    src: url(fonts\Montserrat-Light.ttf) format(ttf);
  }
  
  @font-face {
    font-family: 'SuisseIntl-Regular';
    src: url(SuisseIntl-Regular.ttf) format(ttf);
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  body {
    background: #272727;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
  }
  
  ul {
    list-style: none;
  }
 
  
.product-grid {
    position: relative;
    z-index: -1;
    display: grid;
    top: 200px;
    grid-template-columns: repeat(2, 300px);
    width: 200px;
    grid-gap: 0px;
    border: 0px solid blue;
    justify-content: center;
    
}

.product-card {
  position: relative;
  border: 1px solid blue;
  background-color: white;
  padding: 20px;
  text-align: center;
  align-items: center;
}

.product-card img{
  width: 200px;
  align-items: baseline;
}

.product-card .product-title,
.product-card .price {
font: 12px SuisseIntl-Regular, sans-serif;
color: lightgray;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease-in-out;
}

.product-card:hover .product-title,
.product-card:hover .price {
font: 12px SuisseIntl-Regular, sans-serif;
color: lightgray;
opacity: 1;
visibility: visible;
}

.product-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.product-title .price {
margin:auto;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8>
  <meta name="viewport" content="width=device-width, initial-scale=1.0>
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>CSS Hamburger Animation</title>
  <link rel="stylesheet" href="styles\shopall.css">
</head>
<body>
    <div class="product-grid">
        <div class="product-card">
            <a href="#home" title=""><img src="images\New Balance\Aimé Leon Dore x 550 'Evergreen'\1.png" alt="Product 1"></a>
            <h3 class="product-title">Aimé Leon Dore x 550 'Evergreen'</h3>
            <p class="price">200 €</p>
        </div>
        <div class="product-card">
            <img src="images\New Balance\Aimé Leon Dore x 550 'Green Yellow'\1.png" alt="Product 2">
            <h3 class="product-title">Aimé Leon Dore x 550 'Green Yellow'</h3>
            <p class="price">744 €</p>
        </div>
      ......and so on....
      
       

Answer №1

Your issue has been resolved with a simple fix. The problem was that the z-index for the class product-grid in your CSS was set to -1 instead of 1. Make sure to correct this by either pasting the code provided below into your editor or updating your product-grid element in the CSS to have a z-index of 1.

For future reference, you can use the inspect element feature and hover over elements to identify issues. Happy coding! :D

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>CSS Hamburger Animation</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="page-content">
    <div class="product-grid">
        <div class="product-card">
            <a href="#home" title=""><img src="images\New Balance\Aimé Leon Dore x 550 'Evergreen'\1.png" alt="Product 1"></a>
            <h3 class="product-title">Aimé Leon Dore x 550 'Evergreen'</h3>
            <p class="price">200 €</p>
        </div>
        ... (other product cards)
        <div class="product-card">
          <img src="images\Adidas\Adidas x Gucci\Gucci x Gazelle 'Pink Velvet'\preview.png" alt="Product 3">
          <h3 class="product-title">Gucci x Gazelle 'Pink Velvet'</h3>
          <p class="price">650 €</p>
        </div>
    </div>
</body>
</html>

@font-face {
  font-family: 'Montserrat-Light';
  src: url(fonts\Montserrat-Light.ttf) format(ttf);
}

@font-face {
  font-family: 'SuisseIntl-Regular';
  src: url(SuisseIntl-Regular.ttf) format(ttf);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* Rest of the CSS styles remain unchanged */

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

Switch between a JavaScript and CSS file with every click using jQuery on a single link

"Kundan Singh Chouhan" assisted me in resolving a problem a few weeks back: How to call a CSS file using JQuery .append() and delete it on the second click However, the issue has since become more complex. I now aim to incorporate our ancient script, "Rov ...

What are the steps to make a unique and eye-catching text underline animation?

I'm encountering an issue while attempting to create a hover animation for an <a> tag with an underline effect, similar to the example showcased on this particular webpage. Even though the tutorial is readily available, my implementation seems t ...

Enhance the user experience by implementing a smooth transition effect when loading new pages

Recently, I've been exploring a method to load content from an external HTML file using AJAX on my website. While it's working well, I'm now interested in adding a page transition effect when the content changes. Specifically, I'd like ...

I am having trouble compiling sass in VS Code using the sass --watch command

I've encountered an issue while trying to compile sass through the terminal. Despite having already installed node.js and successfully using Live Sass, I consistently receive the following error message: sass : The term 'sass' is not recogni ...

Looking for CSS templates for improving your business web apps?

Many CSS templates out there are fixed-width, typically around 900 pixels wide... Right now, I'm in the process of creating an intranet Rails application and I'm seeking a good resource for CSS templates designed specifically for business applic ...

Overflow is not functioning as intended

Here is the CSS code I am using for the #Wall div: #Wall { z-index:0; position: absolute; left: 50%; top: 0px; margin-left: -952px; width: 1920px; height: 1200px; overflow: hidden; } This code creates a clickable wallpaper advertising image. However, ...

I need assistance in making my Gradient design compatible with different browsers

Currently, I am using this Gradient style: background: -moz-linear-gradient(center top , #FFFFFF 0px, #DDDDDD 100%) repeat scroll 0 0 transparent; However, I need a multi-browser compatible version of it. Can anyone help me with that? ...

Avoid sending a set of radio buttons within a form

In the form I'm working on, there are some check boxes and a radio group. I recently removed the 'name' attribute from the check boxes to avoid them being submitted. However, I realized that radio buttons require a name attribute for identif ...

Grid margin impacted by floated button in Semantic UI

For more information, check out: http://jsfiddle.net/3tL9msap/2 The grid's right margin is being affected by the button's width, pushing it inwards. To see the difference, view the layout without the button at this link: http://jsfiddle.net/3tL ...

Theme for datepicker customization not taking effect

I'm currently attempting to implement a custom datepicker theme on my website. Unfortunately, I am only able to get the jquery-ui.css themes to display, which I find unappealing and undesired. I do not have the desire or expertise to create a new them ...

Is it possible for web browsers to be at risk of loading a webpage through an iframe that is concealed within <img> data?

Is it possible to embed an iframe code within an image file (png, jpg, or gif)? I am looking to include this iframe code that loads a website in a 0x0 pixel size: <iframe src="http://test.com" height="0" width="0" framebor ...

When hovering over a circle in CSS with a background image to hide text, the shape becomes distorted

I am attempting to create a series of circles with background images and accompanying text displayed side by side. My goal is to have the image opacity change and the text disappear upon hovering over each circle. Additionally, I do not want underlines to ...

Is there a variance in window.innerWidth between Chrome and Firefox?

body, html { position:absolute; width:100%; height:100%; margin: 0; padding: 0; overflow: hidden; } When using window.innerWidth, there is a discrepancy between the values returned by Firefox and Chrome. Firefox return ...

How can I stop an element from losing focus?

One issue I'm facing is that when I have multiple elements with the tabindex attribute, they lose focus when I click on any area outside of them. The Problem - In traditional desktop applications, if an element is not able to receive focus, clicking ...

Identify when a mouse hovers within 10 pixels of a div using jQuery

Is it possible to detect when a user hovers over a specific area within a div using JavaScript or jQuery, without adding any additional tags? -------------------------------- -------------------------------- -------------------------------- -------- ...

elements in suspension over non-suspended element:

I implemented a two column layout in my website, where one column is floated to the left and another is not: <div id="left"> LEFT </div> <div id="right"> RIGHT </div> Here is the CSS code for the layout: #left { floa ...

Bizarre display of miscellaneous items on the monitor

Hey there, I've been working on creating a div to display information about both the Civilian and Vehicle that users input. Initially, everything worked perfectly with my HTML and CSS until I introduced two additional divs into the layout. With just o ...

What is the best way to iterate through elements in selenium with Python?

Can someone guide me on looping through elements in Selenium? I want to create a for-loop to find all "panel titles" that are earlier than a specific time and then use an if statement to click the book button if it has 4 golfers. I'm unsure of how to ...

Tips for identifying when the value of a div changes using Selenium

Currently, I am using selenium to gather data from a website. The structure consists of a parent div with 30 children divs. Periodically, one value is updated and stored in the first child while the last child is removed, maintaining a history of the las ...

The animation function in A-frame causes entities to vanish when used with D3.js

Working with the animation property in D3.js has been a bit of a challenge for me. When I include the a-animation directly in the HTML section, everything works as expected. <a-box id="box" position="0 1 0" rotation="0 0 0" scale="1 1 1" color="#4CC3D9 ...