<section>
  <div class="grid__container">
    <div class="grid__item">Inline Axis</div>
    <div class="grid__item">Block Axis</div>
  </div>
</section>

<div class="form">
  <div class="controle">
    <span>direction:</span>
    <label for="ltr">
      <input type="radio" name="direction" id="ltr" value="ltr" checked />
      ltr
    </label>
    <label for="rtl">
      <input type="radio" name="direction" id="rtl" value="rtl" />
      rtl
    </label>
  </div>
</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;

  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;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 0 6px rgb(0 0 0 / 13%);
  border-radius: 3px;
  gap: 20px;
  min-width: 80vw;
}

.grid__container {
  width: 100%;
  box-shadow: 0 0 0 1px #f36;
  position: relative;
  /*   min-width: 20vmin; */
  /*   min-height: 20vmin; */
}

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

.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;
}
h3 {
  margin: 20px auto;
}

.form {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.button {
  --background: #275efe;
  --rectangle: #184fee;
  --success: #4672f1;
  --text: #fff;
  --arrow: #fff;
  --checkmark: #fff;
  --shadow: rgba(10, 22, 50, 0.24);
  display: flex;
  background: var(--background);
  border-radius: 50%;
  box-shadow: 0 2px 8px -1px var(--shadow);
  color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none 0;
  width: 44px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

#subtract {
  --background: #242836;
  --rectangle: #1c212e;
  --arrow: #f5f9ff;
  --text: #f5f9ff;
  --success: #2f3545;
}

.button:hover {
  transform: scale(0.95);
  box-shadow: 0 1px 4px -1px var(--shadow);
}

.button .button__icon {
  fill: var(--text);
  width: 100%;
  height: auto;
}

.controle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

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

.grid__container {
  display: grid;
  grid-template-columns: repeat(3, 1fr 2fr);
  grid-template-rows: repeat(2, 1fr 2fr);
  writing-mode: horizontal-tb;
  --direction: ltr;
  direction: var(--direction);
}

.grid__item:nth-child(1) {
  grid-column: 2 / span 4;
}

.grid__item:nth-child(2) {
  grid-row: 2 / span 2;
  writing-mode: vertical-lr;
}
const gridContainer = document.querySelector(".grid__container");
const inputs = document.querySelectorAll("input[type='radio']");

inputs.forEach((input, index) => {
  input.addEventListener("click", (etv) => {
    gridContainer.style.setProperty("--direction", 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.