<section>
  <div class="grid__container">
    <div class="grid__item"></div>
    <div class="grid__item"></div>
    <div class="grid__item"></div>
  </div>
</section>

<div class="form">
  <label for="writing-mode">
    writing-mode:
  </label>
  <select name="writing-mode" id="writing-mode">
    <option value="horizontal-tb">horizontal-tb</option>
    <option value="vertical-rl">vertical-rl</option>
    <option value="vertical-lr">vertical-lr</option>
    <option value="sideways-rl">sideways-rl</option>
    <option value="sideways-lr">sideways-lr</option>
  </select>
  <label for="direction">direction:</label>
  <select name="direction" id="direction">
    <option value="ltr">ltr</option>
    <option value="rtl">rtl</option>
  </select>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");

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

body {
  inline-size: 100vw;
  min-block-size: 100vh;

  display: flex;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  font-family: "Exo", Arial, sans-serif;
  background-color: #f7f7f7;

  padding: 20px;
}

section {
  margin: 0 auto;
  box-shadow: 0 0 0 6px rgb(0 0 0 / 13%);
  border-radius: 3px;
  min-inline-size: 80vmin;
  max-block-size: 80vmin;
}

.grid__container {
  inline-size: 100%;
  box-shadow: 0 0 0 1px #f36;
  position: relative;
}

.grid__item {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f7f7f7;
  position: relative;
  counter-increment: item;
  padding: 10px;
}

.grid__item::before {
  content: "i" counter(item);
  color: #fff;
  font-size: 1.2rem;
  padding: 10px;
  text-shadow: 1px 1px 0 rgba(0 0 0 / 0.25);
  background-color: rgb(0 0 0 / 0.6);
  background-image: conic-gradient(
    from 90deg at 40% -25%,
    #ffd700,
    #f79d03,
    #ee6907,
    #e6390a,
    #de0d0d,
    #d61039,
    #cf1261,
    #c71585,
    #cf1261,
    #d61039,
    #de0d0d,
    #ee6907,
    #f79d03,
    #ffd700,
    #ffd700,
    #ffd700
  );
  inline-size: 32px;
  aspect-ratio: 1 / 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  filter: drop-shadow(0 0 3px rgb(255 255 255 / 0.5));
}

.grid__item:nth-child(n + 1) {
  background-color: #f1c2c6;
}

.grid__item:nth-child(2n + 1) {
  background-color: #dac2f1;
}

.grid__item:nth-child(3n + 1) {
  background-color: #ccf1c2;
}

.grid__item:nth-child(4n + 1) {
  background-color: #c2e9f1;
}

.grid__item:nth-child(5n + 1) {
  background-color: #f1ebc2;
}
.grid__item:nth-child(6n + 1) {
  background-color: #09f;
}

.grid__item:nth-child(7n + 1) {
  background-color: #ff5722;
}

.grid__item:nth-child(8n + 1) {
  background-color: #8bc34a;
}

.grid__item:nth-child(9n + 1) {
  background-color: #f66803;
}
1 .grid__item:nth-child(10n + 1) {
  background-color: #0d815f;
}
.grid__item:nth-child(11n + 1) {
  background-color: #28d1c2;
}
.grid__item:nth-child(12n + 1) {
  background-color: #4a28d1;
}
.form {
  text-align: center;
  inline-size: 100%;
}
.grid__container {
  display: grid;
  grid-template-columns: repeat(4, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 10px;
  writing-mode: var(--writing-mode, horizontal-tb);
  direction: var(--direction, ltr);
}

.grid__item:nth-child(1) {
  grid-area: 1 / 1 / 3 / 3;
  justify-self: end;
}

.grid__item:nth-child(2) {
  grid-area: 2 / 3 / 4 / 5;
  place-self: center;
}

.grid__item:nth-child(3) {
  grid-area: 1 / 3 / 2 / 5;
  align-self: end;
}
const grid = document.querySelector(".grid__container");
const selects = document.querySelectorAll("select");

selects.forEach((select) => {
  select.addEventListener("change", (etv) => {
    grid.style.setProperty(`--${etv.target.id}`, etv.target.value);
  });
});
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.