JSFiddle - React, Tailwind, and code Playground
by Jimmy Mabey
HTML
<main>
<section id="top">Branding Top</section>
<header></header>
<section id="content">
<section id="left">Branding Left</section>
<section id="square"></section>
<section id="right">Branding Right</section>
</section>
<footer id="controls">
</footer>
<section id="bottom">Branding Bottom</section>
</main>
CSS
html, body {
margin: 0;
height: 100%;
}
main {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
@media (min-aspect-ratio: 9/16) {
header {
background: red;
height: 20%;
}
footer {
background: blue;
height: 20%;
}
#top, #bottom { display: none; }
}
#content {
display: flex;
justify-content: center;
flex: 1;
background: green;
}
#left, #right {
flex: 1;
text-align: center;
line-height: 2em;
}
#square
{
background: purple;
}
@media (max-aspect-ratio: 9/16) {
#square {
width: 100vw;
height: 100vw;
}
#left, #right { display: none; }
}
JavaScript
function r()
{
var el = $('#square');
var ww = $(window).width(), wh = $(window).height();
var eh = el.height();
if (wh/ww < 1.4) {
el.height('auto');
el.width(el.height());
}
else {
el.height(ww);
el.width(ww);
}
}
$(window).resize(r);
r();