{"id":373508,"date":"2022-10-13T08:10:15","date_gmt":"2022-10-13T15:10:15","guid":{"rendered":"https:\/\/css-tricks.com\/?p=373508"},"modified":"2022-12-08T08:07:09","modified_gmt":"2022-12-08T16:07:09","slug":"a-pure-css-gallery-focus-effect-with-not","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/a-pure-css-gallery-focus-effect-with-not\/","title":{"rendered":"A Pure CSS Gallery Focus Effect with :not"},"content":{"rendered":"\n

Oftentimes in the past, I needed to figure out how to add styles to all elements inside the container but not<\/em> the hovered one.<\/p>\n\n\n\n

\"Animated
Demo of the expected “fade-out” effect on siblings to let users “focus” on a particular element.<\/figcaption><\/figure>\n\n\n\n

This effect requires selecting the siblings of a hovered element. I used to apply JavaScript for this, adding or removing the class that defined the proper CSS rules on mouseenter<\/code> and mouseleave<\/code> events, similar to this:<\/p>\n\n\n\n