JSFiddle - React, Tailwind, and code Playground

by marcandrews

HTML

<div class="parent">
    <div class="child">
        <div>Aspect is kept when resizing</div>
    </div>
</div>

CSS

.parent {
    position: relative;
    width: 75%;
}
.child {
    position: relative;
    padding-bottom: calc(100% * 9 / 16);
}
.child > div {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: blue;
    color: white;
    font-size: 24px;
    text-align: center;
}