I want to target the .drop class when I hover on the .categories class, it is possible to do this with css only?
Asked
Active
Viewed 108 times
0
-
3Nope. Also, please provide your code as text and not as an image ;) – morkro Dec 29 '14 at 09:22
-
no possible with `CSS` use `JS` – Vitorino fernandes Dec 29 '14 at 09:25
-
possible duplicate of [How to affect other elements when a div is hovered](http://stackoverflow.com/questions/4502633/how-to-affect-other-elements-when-a-div-is-hovered) – ale Dec 29 '14 at 09:26
1 Answers
3
div {
width: 200px;
height: 200px;
float:left;
margin: 10px;
border: 1px solid #333;
}
.categories:hover ~ .drop {
background-color: red;
}
<div class="categories">categories</div>
<div class="drop">drop</div>
I am afraid you can not target an element that is up to the DOM relatively to the hovered element only with CSS. You can achieve this with jQuery like so:
$('.categories').hover(function() {
$('.drop').css({ // your code })
});
If the HTML was something like this check snippet:
<div class="categories"></div>
<div class="drop"></div>
you could do this:
.categories:hover ~ .drop {
/* css rules */
}

kapantzak
- 11,610
- 4
- 39
- 61