Div element failing to respond to hover effect

I have implemented a hover effect to display an icon overlay and filter on the Instagram feed of a website I am currently working on. Everything looks perfect when I inspect the element and set the state to hover. However, when I test the website and hover over the images, the hover effect does not show up.

Why is the hover state not being acknowledged?

#insta-feed>a>img,
.ig__overlay--container {
  width: 25vw !important;
  height: 25vw !important;
}

.ig__overlay--container {
  left: 0px;
  background-color: rgba(0, 0, 0, 0);
  background-size: 25px 25px;
  background-position: center center;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 300;
}

.overlay__container {
  position: absolute;
  pointer-events: none;
  z-index: 300;
}

#insta-feed>.overlay__container>div.ig__overlay--container:hover {
  background-color: rgba(0, 0, 0, 0.3);
  background-image: url({{ 'icon-socialig-menu.svg' | asset_url }} );
}
<div class="social__container">
  <div id="insta-feed" style="text-align: center;">
    <div class="flex flex-row overlay__container">
      <div class="ig__overlay--container">
      </div>
      <div class="ig__overlay--container">
      </div>
      <div class="ig__overlay--container">
      </div>
      <div class="ig__overlay--container">
      </div>
    </div
</div>

Answer №1

It's possible that my understanding is flawed, but it seems like the pointer-events property, which is set to inherit by default, is causing the child element div.ig__overlay to take on the value of pointer-events: none from its parent. This could be why you are able to manually change the state even though mouse events are not normally detected.

reference: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events?v=different_example

"The element itself does not respond to mouse events; however, if its descendants have different values for pointer-events, then mouse events can target those specific descendants. In such cases, event listeners on the parent element will still be triggered during the event capture and bubble phases as necessary."

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

Struggling to access your account on the Django website?

I'm having trouble creating a login page in Django. I have completed the views, HTML, and everything, but the problem is that when I try to log in, it doesn't work. After some debugging, I found that the user value is None, but I don't under ...

Tips for making an appended element match the height of an image

After embedding the div .soonOverlay into specific .smallCatalogBlock's, I am facing difficulty in adjusting the height of soonOverlay to match only the height of the img within smallCatalogBlock. Currently, its height extends throughout the entire co ...

Unable to assign a scroll event delegation by using the "on" method

When attempting to delegate a scroll event in order for my element to maintain the same handler after being returned by an ajax call, I utilized the on method for delegation. $('body').on({ scroll:function(){ alert('scrolling&ap ...

Completing two tasks with a single form submission and a single button press

I'm currently working on a script that inserts data into a database using a form. I'm trying to figure out how to trigger another action in a different section after the insertion. Any insights or tips would be greatly appreciated! ...

When I attempt to run JavaScript code on the server, it fails to execute properly

When I run my code on my PC without putting it on the server, it works perfectly fine. However, when I upload it to the server and try to call it, I encounter the following error: Uncaught ReferenceError: crearLienzo is not defined at onload ((index): ...

Why isn't the background of the container div at the top when using multiple CSS sheets?

I am revitalizing a dull website and seeking feedback on my template design here: Check out the ideal look It's quite lovely! However, as I attempt to incorporate my background, menu, and footer elements, I seem to be experiencing issues with my con ...

When using Italics, the conflict arises between the specified line-height and the actual height of the

Recently, I encountered an issue that has me a bit perplexed: I have a span element with line-height set to 18px and font-size at 16px. Everything works perfectly when the text inside is regular; the height of the span remains at 18 pixels. The problem a ...

How to create centered striped backgrounds in CSS

Attempting to achieve a background similar to the one shown Can this be accomplished using CSS? ...

Can a LiveCode translator be developed for my app that can translate all text within the application?

I'm interested in developing a translator within my LiveCode app that can translate any text. I attempted to integrate Google Translate, but it didn't work as expected. Thank you! ...

Why doesn't the div click event trigger when the mouse hovers over an iframe?

My dilemma involves a div element with a click event. When the div is positioned over an iframe area (closer to the user than the iframe), the click event fails to trigger. However, if the div is located elsewhere and not above the iframe, the click event ...

Employing Ajax for interacting with a database

I am attempting to query my database using a JavaScript function for the first time, and I am struggling to get it to work. While unsure if this is the correct approach, it is the one that I have come across. Below is a simple snippet of my HTML code: < ...

What is the best way to apply styling to an image that is contained within the document.write function?

I'm looking to customize the design of this cat image, but I'm struggling to locate where to incorporate the div class. It's likely a basic step, but as a beginner in JavaScript, I'm hoping that someone can assist me. document.write(&ap ...

The alignment of SVG is not in sync with the aspect ratio

I've been struggling with this issue for some time now, trying to align the SVGs correctly for different width and height values. My viewBox has an aspect ratio of 16:9, and I want to scale the SVG accordingly. It's working fine for certain combi ...

Is there a way to adjust the background hues of a React component when a click event is triggered?

Currently, I have 3 React components that each consist of a div element. When I click on one component, I want to change its background color to black. If I then select another component, the previously selected component should return to its normal back ...

Iframe Loading at Lightning Speed

I have set up a script to load my iframe, but I noticed that the script loads the iframe content too quickly. Is there a way for me to configure it to preload all CSS images and content in the background before showing the full iframe content? Here is my ...

When I include scroll-snap-type: y; in the body tag, the scroll-snapping feature does not function properly

Hey there! I've been trying to implement scroll-snapping on my project but unfortunately, I couldn't get it to work. I tested it out on both Chrome and Firefox, but no luck so far. Here's the code snippet I've been working with, would a ...

Place items at the lower part of the container rather than the top

My <ul> has a fixed height and I want the <li> elements inside it to stack at the bottom instead of the top. I attempted using vertical-align: bottom on the <ul>, but that didn't have any effect. The <li> content may overflow ...

Choose the descendant element of the element that has a specific attribute

One of the issues I am facing is related to a button with a span tag inside for the text. Occasionally, this button might be disabled, and my goal is to have it appear grey when in that state. However, I am encountering difficulties making this work proper ...

The functionality of @Output and custom events appears to be malfunctioning

I am a beginner in Angular and attempting to pass data between child and parent components. In the child component.ts file: @Output() doubleClick = new EventEmitter<string>(); onDoubleClick(nameAccount: string){ this.doubleClick.emit(nameAccoun ...

Creating CSS styles to ensure text takes up the largest size possible without wrapping or extending beyond the screen borders

Looking for a way to display text at its maximum size without any wrapping or overflowing the screen? I attempted using @media and adjusting font-size, but things got too complex. My goal is to have the text on example.com displayed at the largest possible ...