<header>
<div class="control">
<label for="justify-content">justify-content:</label>
<select name="justify-content" id="justify-content">
<option value="normal">normal</option>
<optgroup label="content-distribution">
<option value="space-between">space-between</option>
<option value="space-around">space-around</option>
<option value="space-evenly">space-evenly</option>
<option value="stretch">stretch</option>
</optgroup>
<optgroup label="overflow-position">
<option value="unsafe">unsafe</option>
<option value="safe">safe</option>
</optgroup>
<optgroup label="content-position">
<option value="center">center</option>
<option value="start">start</option>
<option value="end">end</option>
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
</optgroup>
<option value="left">left</option>
<option value="right">right</option>
</select>
</div>
<div class="control">
<label for="align-content">align-content:</label>
<select name="align-content" id="align-content">
<option value="normal">normal</option>
<optgroup label="baseline-position">
<option value="baseline">baseline</option>
<option value="first baseline">first baseline</option>
<option value="last baseline">last baseline</option>
</optgroup>
<optgroup label="content-distribution">
<option value="space-between">space-between</option>
<option value="space-around">space-around</option>
<option value="space-evenly">space-evenly</option>
<option value="stretch">stretch</option>
</optgroup>
<optgroup label="overflow-position">
<option value="unsafe">unsafe</option>
<option value="safe">safe</option>
</optgroup>
<optgroup label="content-position">
<option value="center">center</option>
<option value="start">start</option>
<option value="end">end</option>
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
</optgroup>
</select>
</div>
</header>
<div class="container flex-container">
<div class="item" style="--color:#F44336;"></div>
<div class="item" style="--color:#E91E63;"></div>
<div class="item" style="--color:#9C27B0;"></div>
<div class="item" style="--color:#3F51B5;"></div>
<div class="item" style="--color:#2196F3;"></div>
<div class="item" style="--color:#009688;"></div>
<div class="item" style="--color:#CDDC39;"></div>
<div class="item" style="--color:#FFC107;"></div>
<div class="item" style="--color:#607D8B;"></div>
<div class="item" style="--color:#3E989B;"></div>
</div>
<div class="container flex-container direction-column">
<div class="item" style="--color:#F44336;"></div>
<div class="item" style="--color:#E91E63;"></div>
<div class="item" style="--color:#9C27B0;"></div>
<div class="item" style="--color:#3F51B5;"></div>
<div class="item" style="--color:#2196F3;"></div>
<div class="item" style="--color:#009688;"></div>
<div class="item" style="--color:#CDDC39;"></div>
<div class="item" style="--color:#FFC107;"></div>
<div class="item" style="--color:#607D8B;"></div>
<div class="item" style="--color:#3E989B;"></div>
</div>
<div class="container grid">
<div class="item" style="--color:#F44336;"></div>
<div class="item" style="--color:#E91E63;"></div>
<div class="item" style="--color:#9C27B0;"></div>
<div class="item" style="--color:#3F51B5;"></div>
<div class="item" style="--color:#2196F3;"></div>
<div class="item" style="--color:#009688;"></div>
<div class="item" style="--color:#CDDC39;"></div>
<div class="item" style="--color:#FFC107;"></div>
<div class="item" style="--color:#607D8B;"></div>
<div class="item" style="--color:#3E989B;"></div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
counter-reset: section;
font-family: "Exo", Arial, sans-serif;
font-size: 20px;
font-weight: 600;
padding: 10px;
box-sizing: border-box;
background-color: #222;
color: #777;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 100px 1fr;
gap: 10px;
}
header {
grid-column: span 3;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
}
header label {
margin: 0 5px;
}
.container {
border: 1px dotted #fff;
counter-reset: section;
max-height: calc(100vh - 160px);
position: relative;
}
.item {
border: 1px solid #000;
border-radius: 10px;
font-size: 1em;
background-color: #3e989b;
background-color: var(--color);
color: white;
display: grid;
}
.item::before {
counter-increment: section;
content: counter(section);
justify-self: center;
align-self: center;
color: white;
}
.flex-container {
display: flex;
flex-wrap: wrap;
padding: 10px;
gap: 10px;
}
.flex-container .item {
min-width: 70px;
min-height: 70px;
}
.direction-column {
flex-direction: column;
}
.grid {
display: grid;
grid-template-columns: repeat(5, 70px);
grid-template-rows: repeat(3, 70px);
padding: 10px;
gap: 10px;
height: 100%;
width: 100%;
}
.flex-container::before {
content: "display: flex; flex-wrap: wrap";
position: absolute;
left: 0;
bottom: calc(100% + 5px);
color: #fff;
font-size: 12px;
}
.flex-container.direction-column::before {
content: "display: flex; flex-wrap: wrap; flex-direction: column";
}
.grid.container::before {
content: "display: gird;grid-template-columns: repeat(5, 70px); grid-template-rows: repeat(3, 70px)";
position: absolute;
left: 0;
bottom: calc(100% + 5px);
color: #fff;
font-size: 12px;
}
:root {
--justify-content: normal;
--align-content: normal;
}
.container {
justify-content: var(--justify-content);
align-content: var(--align-content);
}
const rootElement = document.documentElement;
const selects = document.querySelectorAll("select");
selects.forEach((select) =>
select.addEventListener("change", (e) => {
rootElement.style.setProperty(`--${e.target.id}`, e.target.value);
})
);
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.