D
D
Danil2017-10-11 18:23:05
css
Danil, 2017-10-11 18:23:05

How to replace css of 2 divs when hovering over any link?

There are two versions of the logo: gray (inactive) and red (active). ( div id="logo" )
The site has a background image ( div id="bg" ).
It is necessary to make sure that when you hover over any link placed through the a tag, the logo changes to red and a red image appears over the background image. By the way, this image is now inserted through the div class="overlay" tag, and display: none is set in CSS . I don't know how to make it only activate on hover.
I tried to implement it with a:hover + .overlay + #logo , I tried with a:hover + .overlay. But this only works when the image and the link are in the same div and in a certain order, and I want this to work regardless of the div.
It doesn't matter what it will be written on (CSS, JS) - the main thing is that it works.
The result should look like this:
Before:
59de33bb70f69145880005.png
After hovering over any link:
59de33c3c47d3577372470.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Cherniavsky, 2017-10-11
@DPritu

Somehow like this :)

$(function () {
  $('a').hover(function () {
    $('.overlay').fadeToggle(200);
    $('#logo').toggleClass('is-active');
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question