JSFiddle - React, Tailwind, and code Playground
HTML
<div class="neat">This is an attempt to keep ratio-sized blocks within the viewport on devices with small heights. Make the viewport +-600px high, and resize this motherflippin' page!</div>
<div class="col">
<div class="square">
<div class="square-inner">
<p>This square is always square, but can extend outside of the viewport</p>
</div>
</div>
</div>
<div class="col">
<div class="square mw">
<div class="square-inner">
<p>This square's width is constrained to 90% of the viewport height.</p>
<p>Its padding does not respect the value of the width when it has been affected by vh units, and continues to increase in height as the window becomes wider</p>
</div>
</div>
</div>
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-family: sans-serif;
font-weight: 100;
}
.neat {
width: 50%;
max-width: 600px;
min-width: 320px;
margin: 0 auto;
}
.col {
float: left;
padding: 2rem;
width: 90vh;
max-width: 50%;
}
.square {
position: relative;
height: 0;
padding-bottom: 100%;
overflow: hidden;
}
.square-inner {
position: absolute;
background-color: #333333;
color: white;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 1.5rem;
}
.mw {
max-width: 90vh;
}