Hovereffect with opacity on gallery
Hi, I'd like to make a hovereffect on a gallery where if you hover on the whole gallery, the opacity lowers except for the image you are hovering on within that gallery.
Actually something like this: https://secretlab.eu/nl/products/magnus-metal-desk?sku=MagBdl15S-C9 (scroll a little down, about 60% on the page is that gallery)
Here is my codepen: https://codepen.io/axl-prudhomme/pen/BaPYJjq?editors=1100
I hope I explained it well.
7 Replies
add active class to hovered img and then do this
do you mean that only the hovered image should have the class active?
yes
no need for the .active class. just say :not(:hover)
oh yeah lol sometimes the easiest solutions skip my mind 🤣
oh wow, i really need to deepdive in the :not(), i don't really understand it yet
thanks!
the only disadvantage is that if the gallery is hovered without actually hovering an item (for example with gaps or margins), it will give all items the opacity.
with the has selector (currently only in chrome) you can do this
with this it only acts if the the gallery really has an item that is hovered