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

<form action="">
  <div class="controls">
    <label for="direction">direction:</label>
    <select id="direction">
      <option value="ltr">ltr</option>
      <option value="rtl">rtl</option>
    </select>
  </div>
  <div class="controls">
    <label for="writingmode">writing-mode:</label>
    <select id="writingmode">
      <option value="horizontal-tb">horizontal-tb</option>
      <option value="vertical-lr">vertical-lr</option>
      <option value="vertical-rl">vertical-rl</option>
      <option value="sideways-rl">sideways-rl</option>
      <option value="sideways-lr">sideways-lr</option>
    </select>
  </div>
</form>
@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;

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

  padding: 20px;
}

section {
  max-width: 60vw;
  width: 100%;
  margin: 0 auto;
}

.grid__container {
  border: 1px dashed #f36;
  box-shadow: 0 0 0 6px rgb(0 0 0 / 13%);
  border-radius: 1px;
}

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

.grid__item::before {
  content: counter(item);
  color: #fff;
  font-size: 3rem;
  text-shadow: 1px 1px 0 rgba(0 0 0 / 0.25);
}

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

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

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

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

.grid__item:nth-child(5) {
  background-color: #f1ebc2;
}
.grid__item:nth-child(6) {
  background-color: #3f51b5;
}

.grid__item:nth-child(7) {
  background-color: #810d16;
}

.grid__item:nth-child(8) {
  background-color: #4d0d81;
}

.grid__item:nth-child(9) {
  background-color: #0d4e81;
}

.grid__item:nth-child(10) {
  background-color: #0d815f;
}
.grid__item:nth-child(11) {
  background-color: #2196f3;
}
.grid__item:nth-child(12) {
  background-color: #ff5722;
}

form {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 20px;
  gap: 10px;
}

form label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

:root {
  --direction: ltr;
  --writingMode: horizontal-tb;
}

.grid__container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 100px);
  grid-auto-rows: 60px;
  gap: 20px;

  direction: var(--direction);
  writing-mode: var(--writingMode);
}
const writingMode = document.getElementById("writingmode");
const direction = document.getElementById("direction");
const flexFlow = document.getElementById("flexFlow");

const documentElement = document.documentElement;

writingMode.addEventListener("change", function (evt) {
  documentElement.style.setProperty("--writingMode", evt.target.value);
});

direction.addEventListener("change", function (evt) {
  documentElement.style.setProperty("--direction", evt.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.