Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't click the button because of the overlay?

This is the HTML

<li id="nav1" class="navs"><a unselectable="on" draggable="false" class="Navigation" href="http://youtube.com">YouTube</a></li>

This is the CSS

.navs:after {
  content: "";
  position: absolute;
  top: 0;  left: 0;  right: 0;  bottom: 0;
  background: #0d0d0d;
  opacity: 0.5;
  transform: scaleY(0);
  transform-origin: 0 100%;
  transition: all .2s ease-out;
}
.navs:hover:after{
  transform: scaleY(1);
}
.navs:active:after{
    background: #FFFFFF;
}

I think the reason why i can't click the button is because when i click the button, the overlay forms. I do not want to remove the overlay though. Is there any way to click through the overlay?

like image 401
REVENTONMC Avatar asked Apr 28 '16 23:04

REVENTONMC


People also ask

Why is my HTML button not clickable?

A disabled button is unusable and un-clickable. The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the button clickable again.

How do I disable a button in CSS?

To make the disabled button, we will use the Pure CSS class “pure-button-disabled” with the class “pure-button”. We can also create a disabled button using disabled attribute. Disabled Button used Class: pure-button-disabled: It is used to disable the Pure CSS button.


1 Answers

Option one

You can give your element a higher z-index. This will move your button above the overlay, so you will be able to click it

Option two

You can disable all mouse events on your overlay using pointer-events:none; so the click event will 'fall through' it and the button will register it

Edit: Use pointer-events when you can, let z-index be your backup plan. If you fall back to it, I suggest that you don't use it inline, but write a specific selector for it in your CSS.

like image 67
molbal Avatar answered Sep 28 '22 19:09

molbal