How to Hover Over One element in CSS and see the Change in Other Element

preview_player
Показать описание
The element in which you want effect should be a child element of the parent element in which you hover. CSS effect. Like it if you found it helpful.
Рекомендации по теме
Комментарии
Автор

The effect would also appear when he hovers "Left", because he did the hover for the whole section.

Jonny
Автор

Here's the code that worked for me

section:hover #left + #right {
background-color: coral;
}

remember to add the '+' sign, followed by the element that you want to be affected when you hover over the original element.

MarioDuarteMD
Автор

Thank you very much, it works, I've been looking for this for so long! 🔟👏

dregavero
Автор

I was spending lots of time figuring out this before... thank you for saving my time.. nice video..

magicaz
Автор

Worked for my case, thanks a lot. I will save this example til further :)

AleksaCar-bkrx
Автор

You saved my time and my nerves))) thank you much for the video!

kittycath
Автор

Coudn't even find it on the stackoverflow! Thanks dude!

muhammadhassaanbasil
Автор

why so many dislikes? good tutorial. worked perfect.

MasterZiomekPL
Автор

Can anyone tell me what is the difference between #section:hover #left and #section:hover ~ #left??
What is ~ used for ?

nuraktar
Автор

This is working in this case fine.
But this is not a proper way to make it .
We can achive this thing by using JavaScript

abhijith
Автор

#left:hover #right{
background-color: red;
}

Why this won't work?
someone answer please.

skmahmoodsameer
Автор

#left:hover + div#right {background: coral} ... you're welcome

Tailevu
Автор

Thx
edit: bruh i just found better way just use class

Roxaro
Автор

Wrong logic actually. You should apply the hover on the .#right and not the whole section

This is the right thing
#right:hover+#left{
background: orange
}

inedumozey
Автор

just do this and it will work better then this .

<html>
<head>
<style>
.d1, .d2{
border: 2px solid black;
width: 200px;
height: 100px;
display: inline-block;
margin: 0px 0px;
}
section{
display: inline-block;
}
section:hover .d1{
background-color: aqua;
}

</style>

</head>
<body>
<section>
<div class="d1">d1</div>
<div class="d2">d2</div>
</section>
</body>
</html>

KingKing-nyew
Автор

banana ata na ho to chhod de bhai html kyu logo ki jindagi kharab kar raha he.

kunjyadav