0

What I am trying to achieve is a kind of notification box (a div element). I would like to show it with some opacity. And I need the box to be "invisible" by the events. For example, if the box is on top of a button, I can still click the button through the box.

Some may suggest make it movable by the user, but the current UI does not allow me to do so.

Can it be achieved by any mean? HTML, CSS, Javascript and jQuery are all available.

My current notification box CSS:

.notification-box {
    position: fixed;
    top: 0;
    left: 100vw;
    transform: translate(-100%, 0);
}
Luke Vo
  • 17,859
  • 21
  • 105
  • 181

2 Answers2

2

Use css pointer events as noted in this post

.notification-box {
    position: fixed;
    top: 0;
    left: 100vw;
    transform: translate(-100%, 0);
    pointer-events: none;
} 

Here is a codepen showing it in action.

Community
  • 1
  • 1
Jacob Petersen
  • 1,463
  • 1
  • 9
  • 17
1

This isn't exactly a duplicate, but the answer to this question is also the answer to your question.

jQuery - Trigger click even on element behind

You can use the CSS pointer-events property:

The CSS property pointer-events allows authors to control under what circumstances (if any) a particular graphic element can become the target of mouse events.

#element {
  pointer-events: none;
}

Or you can trigger the click event:

$('#box').click(function(){
   $('#target').trigger('click')
})
Community
  • 1
  • 1
Goose
  • 4,764
  • 5
  • 45
  • 84