Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to stop only the hover pointer event in css

I have an interactive background that uses css to change opacity on hover. On top of this (absolute positioned) is a text layer. In order to allow for the background to react even with the text on top I have added css pointer-event:none to the div containing text.

This works well, but it would be better if I could still keep the ability to highlight the text.

Does anyone know away to limit which pointer-events are suppressed?

like image 904
Finglish Avatar asked Jul 04 '26 13:07

Finglish


1 Answers

Actually you can't do what you want. If you disable pointer-event, text can't be selected. But you can do this functional by some jquery magic.

first you put background hover effects into some class:

.hov{background: black !important;} //just example

then assign it to hover effect:

$('#wrap').hover(function() {
    $('#wrap').toggleClass("hov");
});

and translate hover event from you block into you background:

$('#block').hover(function(e) {
    $('#wrap').trigger(e.type);
});

So look into fiddle and you'll understand

EXAMPLE

like image 126
raskalbass Avatar answered Jul 07 '26 09:07

raskalbass



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!