<div class="aspectratio" style="--aspect-ratio: 4/3"></div>
<div class="aspectratio" style="--aspect-ratio: 16/9"></div>
<div class="aspectratio" style="--aspect-ratio: 3/2"></div>
<div class="aspectratio" style="--aspect-ratio: 1.85/1"></div>
<div class="aspectratio" style="--aspect-ratio: 2.39/1"></div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100vw;
  min-height: 100vh;
  font-family: "Exo", Arial, sans-serif;
  background-color: #222;
  color: #fff;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  font-size: 1.5rem;
  gap: 10px;
  padding: 10px;
}

.aspectratio {
  aspect-ratio: var(--aspect-ratio);
  font-size: 14px;
  background-color: #09f;
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: flex-start;
}

.aspectratio::after {
  content: attr(style);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.