JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="box">
<img src="https://picsum.photos/200/300/?random" alt="">
</div>
</div>
CSS
/* general */
html {
width: 100%;
box-sizing: border-box;
padding: 0;
margin: 0;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.container {
position: relative;
/* give the container any width and height you need */
width: 100%;
height: 80vh;
/* just for demo not needed */
border: 1px solid black;
/* just for demo not needed */
overflow: hidden;
/* just for demo not needed */
}
.box {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
}