Why are only the elements after the toggle working in this code snippet that animates visibility? The ones before don't seem to be affected. Any ideas on why this behavior is occurring?
I'm testing this code in the latest version of Chrome.
.element-1 {
transform-origin: top;
transform: scaleY(1);
transition: all 0.5s ease-out;
overflow: hidden;
}
input[type="checkbox"]:checked~.element-1 {
transform: scaleY(0);
transition: all 0.5s ease-in;
}
<div class="element-1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Nulla faucibus nisi nec ullamcorper finibus.</p>
</div>
<div class="element-1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Nulla faucibus nisi nec ullamcorper finibus.</p>
</div>
<input type="checkbox" id="toggle">
<label for="toggle">Toggle Element</label>
<div class="element-1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Nulla faucibus nisi nec ullamcorper finibus.</p>
</div>
<div class="element-1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Nulla faucibus nisi nec ullamcorper finibus.</p>
</div>