JSFiddle - React, Tailwind, and code Playground
HTML
<div style="margin-top: 500px">TEXT</div>
<div class="transform">TRANSFORM</div>
<div class="div1">
<img src="https://via.placeholder.com/500">
</div>
<div class="div2">
<span>TEXT</span>
</div>
CSS
.transform {
background-color: slategray;
}
.transform:hover~.div1 {
height:0; padding-top:0; padding-bottom:0; /* need to adjust height and padding */
}
.div1 {
background-color: royalblue;
padding: 15px;
height: 200px;
transition: padding-top 2s, padding-bottom 2s, height 2s; /* animate the padding too */
transform-origin: top center;
}
.div2 {
background-color: springgreen;
font-size: 20px;
}
img {
width:200px; height: 100%; vertical-align:top; /* and some adjustments here */
}