JSFiddle - React, Tailwind, and code Playground

HTML

<div class="outer"><div class="inner">1</div></div>

<div class="outer fix"><div class="inner">2</div></div>

CSS

.outer {
    display: flex;
    flex-flow: column;
    height: 200px;
    justify-content: center;
    border: 1px solid red;
    margin: 20px 20px 110px;
}

.fix {
    justify-content: space-between;
}
.fix::before, .fix::after {
    content: '';
    display: block;
    flex: 0 0 0px;
}

.inner {
    border: 20px solid rgba(255,255,255,.5);
    background: rgba(255,255,128,.8);
    flex: 0 0 auto;
    animation: change-height 10s infinite;
}

.fix .inner {
    background: rgba(128,255,128,.8);
}

@keyframes change-height {
    0%, 100% { height: 100px; }
    50% { height: 300px; }
}