JSFiddle - React, Tailwind, and code Playground

by joshmoto

HTML

<div class="window">

  <div class="translate">

    <div class="ratio">



    </div>

  </div>

</div>

SCSS

BODY {
  border: 10px solid white;
}

.window {
  position: absolute;
  top: 5px;
  left: 5px;
  bottom: 5px;
  right: 5px;
  display: block;
  overflow: hidden;
  background: blue;
  
  .translate {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translate(50%, 50%);
    
    .ratio {
      height: 100%;
      max-height: 400px;
      max-width: 600px;
      width: 150px;
      background: red;
      transform: translate(-50%,-50%);
    }
  }
  
}