I am trying to toggle the display of two sibling elements when I hover on the first sibling. I want to change the display of the hovered first sibling element from block to none while its immediate or next sibling element's style changes to block from none. I was able to write a css code for that but on hover, the elements constantly flicker and alternate in a never ending loop. Below is my html and css code:
.box {
display: inline-block;
width: 300px;
height: 150px;
margin: 20px 40px;
border-radius: 4px;
cursor: pointer;
}
.box-one {
background: green;
}
.box-two {
background: whitesmoke;
display: none;
}
.box-one:hover {
display: none;
}
.box-one:hover+.box-two {
display: block;
}
<div class="box box-one"></div>
<div class="box box-two"></div>