The suggested duplicated don't have a solution for this problem and don't hurry to close it. I'm a CSS expert.
I have 2 elements having the same parent and when the first element disappears with display: none
, the second element moves to the top, taking place of the first one. Is there a transition that can be added for the movement of the second element?
See the sinppet below. Click on the red block to make it disappear and then click on the green one to show it back.
document.querySelector(".first").onclick = function(event) {
this.style.display = "none";
}
document.querySelector(".second").onclick = function(event) { document.querySelector(".first").removeAttribute("style")
}
.first {
background: red;
height : 250px;
}
.second {
background : green;
height : 250px;
}
<div>
<div class="first">My element</div>
<div class="second">Another element</div>
</div>