JSFiddle - React, Tailwind, and code Playground
by Chuan Shao
HTML
<div class="parent">
<div class="container1 container"></div>
<div class="container2 container"></div>
</div>
CSS
*
{
margin:0;padding:0;
}
.parent {
display: flex;
justify-content: center;
}
div.container
{
width: 50vw;
height: 50vw;
max-height: 100vh;
max-width: 100vh;
background-size: contain;
background-repeat: no-repeat;
background-position: 50%;
}
.container1 {
background-color: red;
background-image: url('https://img3.doubanio.com/lpic/s4554820.jpg');
}
.container2 {
background-color: green;
background-image: url('http://pagead2.googlesyndication.com/simgad/10067268081911489671');
}