Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove clicking from element when opacity is at 0%

I have some content on a page that needs fading to 0% opacity rather than fading out and having the element being totally removed from the page, so the height and width of the element is still there but just inactive.

The problem is, the objects in that element are still clickable and still fire events. Is there a special way of making them inactive or is it quite simply cursor:default; and preventDefault();?

like image 232
Oliver Tappin Avatar asked Dec 06 '25 08:12

Oliver Tappin


2 Answers

Try changing the content's visibility.

In css,

visibility: hidden

This will hide the element, but will still occupy the same width and height as when fully shown.

Even better, you can fade out the element, and then change its visibility:

$('#target').animate({
      opacity: 0
    },
    1000, // specifies duration of fade (in milliseconds)
    function() {
        // this function will called after the opacity animation has completed
        $(this).css('visibility', 'hidden');
    }
);
like image 147
Gabriel Florit Avatar answered Dec 10 '25 01:12

Gabriel Florit


For me, it worked this way:

.dropdown-menu {
    transition: all .32s ease;
    opacity: 0;
    display: block;
    visibility: hidden;
}

.show {
    visibility: visible;
    opacity: 1;
}
like image 36
Kevo Avatar answered Dec 10 '25 01:12

Kevo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!