JSFiddle - React, Tailwind, and code Playground
HTML
<div class="grid cs-style">
<div>
<figure>
<div class="bg_red">Верхняя часть</div>
<figcaption>
Наполнение
</figcaption>
</figure>
</div>
</div>
CSS
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.bg_red {
background-color: red;
width: 100%;
height: 150px;
}
.grid {
width: 80%;
margin: 160px 100px 100px 100px;
height: 300px;
list-style: none;
text-align: center;
}
.grid div {
display: inline-block;
width: 100%;
margin: 0;
text-align: left;
position: relative;
}
.grid figure {
margin: 0;
position: relative;
}
.grid figure div {
max-width: 100%;
display: block;
position: relative;
}
.grid figcaption {
position: absolute;
top: 0;
left: 0;
padding: 20px;
background: green;
}
/* Caption Style */
.cs-style figure div {
z-index: 10;
-webkit-transition: -webkit-transform 0.4s;
-moz-transition: -moz-transform 0.4s;
transition: transform 0.4s;
}
.cs-style figure.opened div {
-webkit-transform: translateY(-150px);
-moz-transform: translateY(-150px);
-ms-transform: translateY(-150px);
transform: translateY(-150px);
}
.cs-style figcaption {
height: 150px;
width: 100%;
top: auto;
bottom: 0;
}
JavaScript
$('.cs-style figure').on('click', function (e) {
$( this )[$( this ).hasClass('opened') ? 'removeClass' : 'addClass']('opened');
} );