Firefox and Opera not affected by pointer-events on scrollbars

While working on a CSS dropdown menu, I encountered an issue with the pointer-events property in Firefox 44. Initially, I assumed it was a bug in the newer version of Firefox, but upon testing, I found the same problem in Firefox 25 and even in Opera 18, which is powered by WebKit.

To better illustrate the problem, I created another sample:

div {
  width: 150px;
  height: 200px;
  line-height: 30px;
  background: #DDD;
  /*- overflow-y -*/
  overflow-y: auto;
  /*- pointer events -*/
  pointer-events: none;
}
div:hover {
  background: #D77;
}
<div>
  text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>
</div>

As you can see, the pointer-events property of the div element is set to none, so one would expect the :hover state not to trigger at all.

However, when you move your cursor over the scrollbar in Firefox and Opera, the issue persists.

pointer-events is fully supported by all major browsers, so what could be the problem here? Am I overlooking something?

EDIT:
The issue has been resolved in newer versions of Opera,
but I need it to function properly on common versions of Chrome, Opera, and Firefox. Is there a workaround or an alternative solution?

EDIT 2: Here's the jsfiddle link https://jsfiddle.net/ja0ct9s6/2/
Initially, it appears to work fine,
but if you take your cursor out of the dropdown and move it back in from the right side (where the dropdown is not visible), the scrollbar still appears to trigger the hover effect. (Note: test this in Firefox)

Answer №1

Although not a direct answer to your question, here is a potential solution to your problem based on my understanding:

Have you considered using the visibility property to toggle the visibility of the menu? By setting visibility: hidden, the scroll bars will not be accessible until the menu is made visible.

#navigation>li>ul{
  /*...*/

  /*to hide it by default*/
  visibility: hidden;
  opacity:0;
}

/*hovers*/
#navigation>li:hover>ul{
  visibility: visible;
  opacity:1;
}

Check out the Fiddle for a demonstration.

Furthermore, using pointer-events is unnecessary with this code implementation.

Answer №2

If you're facing a challenge, one workaround to consider is enclosing it within another <div> and allowing that one to overflow. However, this is not a permanent solution but rather a temporary fix. It may not be feasible in your situation, especially if your original code is intricate.

.wrapper {
  width: 150px;
  height: 200px;
  /*- overflow-y -*/
  overflow-y: auto;
}
.wrapper > div {
  line-height: 30px;
  background: #DDD;
  /*- pointer events -*/
  pointer-events: none;
}
.wrapper > div:hover {
  background: #D77;
}
<div class="wrapper">
  <div>
    text
    <br/>text
    <br/>text
    <br/>text
    <br/>text
    <br/>text
    <br/>text
    <br/>text
    <br/>
  </div>
</div>

Answer №3

Not entirely certain about your objective... but maybe this could be of assistance? http://codepen.io/ijmccallum/pen/reMYXN

<div class="container">
  <div class="box">
  text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>text
  <br/>
    </div>
</div>

.container {
  height: 150px;
  width: 150px;
  /*- overflow-y -*/
  overflow-y: scroll;
  overflow-x: hidden;
  /*- pointer events -*/
}
.box {
  line-height: 30px;
  background: #DDD;
  pointer-events: none;
}
.container:hover {
  background: #D77;
}

I enclosed your div within a container with specific dimensions. This results in a scroll bar display and eliminates any odd hovering effects on the child elements.

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

The perspective property creates discrepancies in transform behavior between Firefox and Chrome, resulting in unexpected outcomes

While I found a similar question here, the solutions provided are outdated and do not help in my case. My issue revolves around a turning page effect that utilizes the CSS properties of transform-style:preserve-3d and perspective to create a 3D page. The ...

When the canvas is dragged, an item within it suddenly leaps or bounces

I've noticed that when I drag the canvas using -webkit-transform: translate(x,y), an element on the canvas jumps. Are there any suggestions for addressing this issue? ...

Having trouble getting a resizable DIV inside a 100% height DIV with margin to work properly. Any tips or assistance would be greatly

I've encountered a common issue that is slightly different from others I've come across. Despite my best efforts, I have been unable to find a solution on my own. If anyone could offer me some guidance on this, I would greatly appreciate it. The ...

Attempting to align content in the middle of the page across all web browsers

I need assistance with centering all the content on my website across different screen sizes and browsers. Currently, everything appears off-center and aligned to the left on various screens I have tested. You can view the HTML and CSS code in this link. H ...

Experiencing an unusual gap following the menu on mobile view for my WordPress website?

I recently launched a WordPress website dedicated to education. In order to make some adjustments, I added subheaders to each page with a simple display:none setting. Surprisingly, while everything looked perfect on desktop view, I noticed some extra spa ...

Update the default arrow icon in the expand/collapse navigation bar

I need help changing the downward arrow in the code below to a fontawesome icon. I'm unsure about how to: 1. Remove the default arrow on the right of the parent node. 2. Use "+/-" symbols to represent the collapse state. It seems that the onclick c ...

Tips for avoiding the transmission of className and style attributes to React components

Hey there! I'm working on a custom button component that needs to accept all ButtonHTMLAttributes except for className and style to avoid any conflicts with styling. I'm using TypeScript with React, but I've run into some issues trying to ac ...

Displaying information in a drop-down list based on the selection made in a previous drop

Hey fellow developers, I could really use your expertise on a project I'm working on for attendance management. I've hit a roadblock with a specific feature - my goal is to dynamically display departments based on the selected block without requi ...

How can I use CSS to change the background color of a fixed navbar when scrolling?

Is it possible to use only CSS to alter the background color of a fixed navbar once the user has scrolled past a specific point vertically? I am curious if this can be accomplished in CSS by targeting the ID of another element, or possibly its height? Alt ...

Dealing with a div height problem in HTML/CSS

I'm experiencing an issue where my footer is overlapping with the bottom of my div. I've attached an image for reference but I can't seem to figure out what's causing the problem. I've tried adjusting the height values without succ ...

Using Jquery to toggle classes between "display block" and "display none

Hello friends, I'm in need of some help with my code. $(document).ready(function() { var circle = $('.circle'); $(".send a").click(function(e) { e.preventDefault(); $('.wrap').css('display', 'bl ...

Encountering an unexpected token error while attempting to incorporate JQuery into a React JS project

I am currently diving into the world of React.js and attempting to incorporate a side navigation bar on my homepage. However, I encountered an eslint error when trying to implement the sidebar using jQuery code. Below you will find the code snippet for the ...

What could be causing my divs to overlap?

I recently started coding and I'm facing an issue with my <header> and <section> divs overlapping each other. I was under the impression that being block elements, <section> should be displayed below <header>. Any suggestions o ...

Issue with JavaScript causing circles to form around a parent div

I am struggling to position a set of circles around a parent div in my code. I want 6 circles to form a circle around the parent div, but they are not lining up correctly. Can someone help me identify what I'm doing wrong? var div = 360 / 6; var ra ...

Tips for preventing the inheritance of .css styles in React

I'm facing an issue with my react application. The App.js fragment is displayed below: import ServiceManual from './components/pages/ServiceManual' import './App.css'; const App = () => { return ( <> ...

What might be causing Flex not to function properly on my personalized landing page?

I attempted to create a basic landing page featuring an image background with a logo, button, and a row of 4 images displayed side by side using Flex. However, for some reason, the Flex is not functioning properly for the row of images. Here is the code s ...

Tips for centrally zooming responsive images without altering their dimensions

I have created a custom jQuery and CSS function that allows an image to zoom in and out on mouseover while maintaining a constant box size. I modified an example code to suit my needs. Check out the demo here: https://jsfiddle.net/2fken8Lg/1/ Here is the ...

I can't seem to get my SCSS files to load properly on GitHub HTML pages, and I

Just starting out in the world of programming and decided to showcase my portfolio site on GitHub. While my index page is displaying correctly, I'm encountering issues with some images and all of my SCSS files not showing up. Any assistance or guidanc ...

Can Microsoft Bot Framework chat window support rounded border corners?

Is it possible to style border corners in the Microsoft bot framework? I've attempted the following: const styleSet = window.WebChat.createStyleSet({ botAvatarImage: '/assets/logo.png', bubbleBackground: ...

What is the reason for the Client Height value not affecting other elements?

I'm trying to set the spacing of my sidebar from the top equal to the height of the header. However, when I use clientHeight in JavaScript to get the height and then try to apply it to other elements using marginTop or top values (with position includ ...