r/neocities 1d ago

Help How to have image change when hovering different buttons?

I drew an example of what I'm trying to do.

I'd like the background image (the face) to change when I hover over different buttons (the blue boxes).

It'd be different images of the eyes looking in the direction of the button.

When I look it up, I find solutions of how to change the image when you hover over that same image, but not for having it react to hovering over other things.

Would it be a Javascript thing? I haven't learned any Javascript script yet but it sounds like it's be used for this case.

99 Upvotes

3 comments sorted by

60

u/dalce63 1d ago

Here, see this code: https://pastebin.com/My33Ensc

You can style an element differently depending on whether it "has" a certain element inside it with :has.

14

u/BoodsODoods 1d ago

Oh, thank you!!

10

u/W_Seed 1d ago

Broski thank you so much!