O
O
Oleg2018-01-30 10:48:07
css
Oleg, 2018-01-30 10:48:07

How to make the background color change when hovering over a link?

I would like to implement such a thing: when you hover over a link, a gradient is applied to the background div-a. I made a simple code https://jsfiddle.net/destroer18/oxeum1or/ so as not to throw off the whole one.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
weranda, 2018-01-30
@destroer18

HZ, maybe a jQuery example for your case is suitable:

$('li a.h').hover(function() {
   $('.nav').toggleClass('hovered');
});

And there already and twist the styles.

D
Dima Pautov, 2018-01-30
@bootd

As you wrote, it cannot be done. To change the background of the parent element when hovering over a link. css doesn't have this option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question