<div id="container">
<div class="flex__container" id="flexContainer">
<div class="flex__item"></div>
</div>
<div class="actions">
<div class="toggle" id="add">
<input type="checkbox">
<span class="button"></span>
<span class="label">+</span>
</div>
<div class="toggle" id="reduce">
<input type="checkbox" checked>
<span class="button"></span>
<span class="label">–</span>
</div>
</div>
</div>
<div class="forms">
<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>
<div class="controls">
<label for="flexDirection">flex-direction:</label>
<select id="flexDirection">
<option value="row">row</option>
<option value="row-reverse">row-reverse</option>
<option value="column">column</option>
<option value="column-reverse">column-reverse</option>
</select>
</div>
<div class="controls">
<label for="flexWrap">flex-wrap:</label>
<select id="flexWrap">
<option value="nowrap">nowrap</option>
<option value="wrap">wrap</option>
<option value="wrap-reverse">wrap-reverse</option>
</select>
</div>
<div class="controls">
<label for="alignContent">align-content:</label>
<select id="alignContent">
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
<option value="center">center</option>
<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>
<option value="start">start</option>
<option value="end">end</option>
<option value="baseline">baseline</option>
<option value="first baseline">first baseline</option>
<option value="last baseline">last baseline</option>
</select>
</div>
<div class="controls">
<label for="alignItems">align-items:</label>
<select id="alignItems">
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
<option value="center">center</option>
<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>
<option value="start">start</option>
<option value="end">end</option>
<option value="baseline">baseline</option>
<option value="first baseline">first baseline</option>
<option value="last baseline">last baseline</option>
</select>
</div>
<div class="controls">
<label for="justifyContent">justify-content:</label>
<select id="justifyContent">
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
<option value="center">center</option>
<option value="space-between">space-between</option>
<option value="space-around">space-around</option>
<option value="space-evenly">space-evenly</option>
<option value="start">start</option>
<option value="end">end</option>
<option value="left">left</option>
<option value="right">right</option>
</select>
</div>
<div class="controls">
<label for="gap">gap:</label>
<input type="range" id="gap" name="gap" min="10" max="100" steps="1" value="20" />
</div>
<div class="controls">
<label for="inlineSize">inline-size:</label>
<input type="range" id="inlineSize" name="inlineSize" min="40" max="100" steps="1" value="40" />
</div>
<div class="controls">
<label for="blockSize">block-size:</label>
<input type="range" id="blockSize" name="blockSize" min="40" max="80" steps="1" value="40" />
</div>
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");
@import url(https://fonts.googleapis.com/css?family=Lato:700)
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
width: 100vw;
min-height: 100vh;
margin: 0;
background-color: #291642;
font-family: "Gochi Hand", sans-serif;
font-size: 100%;
letter-spacing: 0.1rem;
color: #fff;
display: grid;
grid-template-columns: 1fr minmax(200px, max-content);
gap: 20px;
}
.forms {
height: 100vh;
overflow-y: auto;
border-left: 4px solid rgba(255,255,0,.1);
display: flex;
flex-direction: column;
padding: 10px;
position: relative;
z-index: 2;
background-color: rgba(0,0,0,.2);
}
.controls {
background-color: rgba(0,0,0,.1);
padding: 5px;
border-radius: .5em;
border: 1px solid rgba(0,0,0,.2);
margin: 5px;
}
.controls select {
font-size: .9em;
max-width: 100px;
min-width: 100px;
}
.toggle {
margin: 4px;
display: inline-block;
}
.toggle {
box-shadow: inset 0 0 35px 5px rgba(0, 0, 0, 0.25), inset 0 2px 1px 1px rgba(255, 255, 255, 0.9), inset 0 -2px 1px 0 rgba(0, 0, 0, 0.25);
border-radius: 8px;
background: #ccd0d4;
position: relative;
height: 140px;
width: 140px;
transform: scale(.5);
}
.toggle:before {
box-shadow: 0 0 17.5px 8.75px #fff;
border-radius: 118.3px;
background: #fff;
position: absolute;
margin-left: -50.4px;
margin-top: -50.4px;
opacity: 0.2;
content: "";
height: 100.8px;
width: 100.8px;
left: 50%;
top: 50%;
}
.toggle .button {
-webkit-filter: blur(1px);
-moz-filter: blur(1px);
filter: blur(1px);
transition: all 300ms cubic-bezier(0.23, 1, 0.32, 1);
box-shadow: 0 15px 25px -4px rgba(0, 0, 0, 0.5), inset 0 -3px 4px -1px rgba(0, 0, 0, 0.2), 0 -10px 15px -1px rgba(255, 255, 255, 0.6), inset 0 3px 4px -1px rgba(255, 255, 255, 0.2), inset 0 0 5px 1px rgba(255, 255, 255, 0.8), inset 0 20px 30px 0 rgba(255, 255, 255, 0.2);
border-radius: 96.32px;
position: absolute;
background: #ccd0d4;
margin-left: -48.16px;
margin-top: -48.16px;
display: block;
height: 96.32px;
width: 96.32px;
left: 50%;
top: 50%;
}
.toggle .label {
transition: color 300ms ease-out;
text-shadow: 1px 1px 3px #ccd0d4, 0 0 0 rgba(0, 0, 0, 0.8), 1px 1px 4px #fff;
line-height: 139px;
text-align: center;
position: absolute;
font-weight: 700;
font-size: 42px;
display: block;
opacity: 0.9;
height: 100%;
width: 100%;
color: rgba(0, 0, 0, 0.4);
}
.toggle input {
opacity: 0;
position: absolute;
cursor: pointer;
z-index: 1;
height: 100%;
width: 100%;
left: 0;
top: 0;
}
.toggle input:active ~ .button {
box-shadow: 0 15px 25px -4px rgba(0, 0, 0, 0.4), inset 0 -8px 30px 1px rgba(255, 255, 255, 0.9), 0 -10px 15px -1px rgba(255, 255, 255, 0.6), inset 0 8px 25px 0 rgba(0, 0, 0, 0.4), inset 0 0 10px 1px rgba(255, 255, 255, 0.6);
}
.toggle input:active ~ .label {
font-size: 40px;
color: rgba(0, 0, 0, 0.45);
}
.toggle input:checked ~ .button {
box-shadow: 0 15px 25px -4px rgba(0, 0, 0, 0.4), inset 0 -8px 25px -1px rgba(255, 255, 255, 0.9), 0 -10px 15px -1px rgba(255, 255, 255, 0.6), inset 0 8px 20px 0 rgba(0, 0, 0, 0.2), inset 0 0 5px 1px rgba(255, 255, 255, 0.6);
}
.toggle input:checked ~ .label {
font-size: 40px;
color: rgba(0, 0, 0, 0.4);
}
:root {
--writingMode: horizontal-tb;
--direction: ltr;
--flexDirection: row;
--flexWrap: nowrap;
--alignContent: flex-start;
--alignItems: flex-start;
--justifyContent: flex-start;
--gap: 20px;
--flexItemBlockSize: 12vh;
}
#container {
writing-mode: var(--writingMode);
direction: var(--direction);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.flex__container {
display: flex;
flex-flow:var(--flexDirection) var(--flexWrap);
place-content: var(--alignContent) var(--justifyContent);
align-items: var(--alignItems);
gap: var(--gap);
inline-size: calc(var(--flexItemBlockSize) * 4 + var(--gap) * 3 + 2px);
block-size: calc(var(--flexItemBlockSize) * 2 + var(--gap) + 2px);
border: 1px dashed #E91E63;
border-color: #FFEB3B #FF5722 #fff #00BCD4;
position: relative;
counter-reset: listCounter;
}
.flex__item {
display: flex;
justify-content: center;
align-items: center;
min-inline-size: var(--flexItemBlockSize);
min-block-size: var(--flexItemBlockSize);
counter-increment: listCounter;
background-image:url('https://www.w3cplus.com/sites/default/files/blogs/2020/2006/frog-green.svg'), linear-gradient(0deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.2));
background-repeat:no-repeat, repeat;
background-position: center, left top;
background-size: var(--flexItemBlockSize) var(--flexItemBlockSize);
position: relative;
background-blend-mode: exclusion;
}
.flex__item::before {
content: counter(listCounter);
font-size: 2rem;
background: linear-gradient(to bottom, #03A9F4, #FF5722);
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
}
View Compiled
const writingMode = document.getElementById("writingmode");
const direction = document.getElementById("direction");
const flexDirection = document.getElementById("flexDirection");
const flexWrap = document.getElementById("flexWrap");
const alignContent = document.getElementById("alignContent");
const justifyContent = document.getElementById("justifyContent");
const alignItems = document.getElementById("alignItems");
const gap = document.getElementById("gap");
const inlineSize = document.getElementById("inlineSize");
const blockSize = document.getElementById("blockSize");
const addButton = document.getElementById("add");
const reduceButton = document.getElementById("reduce");
const flexContainer = document.getElementById("flexContainer");
const documentElement = document.documentElement;
addButton.addEventListener("click", function (evt) {
const createFlexItem = document.createElement("div");
createFlexItem.setAttribute("class", "flex__item");
flexContainer.appendChild(createFlexItem);
});
reduceButton.addEventListener("click", function (evt) {
const flexItem = document.querySelector(".flex__item");
const flexItemAll = document.querySelectorAll(".flex__item");
if (flexItemAll.length === 0) {
return false;
}
if (flexItemAll.length > 0) {
flexContainer.removeChild(flexItem);
}
});
writingMode.addEventListener("change", function (evt) {
documentElement.style.setProperty("--writingMode", evt.target.value);
});
direction.addEventListener("change", function (evt) {
documentElement.style.setProperty("--direction", evt.target.value);
});
flexDirection.addEventListener("change", function (evt) {
documentElement.style.setProperty("--flexDirection", evt.target.value);
});
flexWrap.addEventListener("change", function (evt) {
documentElement.style.setProperty("--flexWrap", evt.target.value);
});
alignContent.addEventListener("change", function (evt) {
documentElement.style.setProperty("--alignContent", evt.target.value);
});
alignItems.addEventListener("change", function (evt) {
documentElement.style.setProperty("--alignItems", evt.target.value);
});
justifyContent.addEventListener("change", function (evt) {
documentElement.style.setProperty("--justifyContent", evt.target.value);
});
gap.addEventListener("change", function (evt) {
documentElement.style.setProperty("--gap", `${evt.target.value}px`);
});
inlineSize.addEventListener("change", function (evt) {
flexContainer.style.inlineSize = `${evt.target.value}vh`;
});
blockSize.addEventListener("change", function (evt) {
flexContainer.style.blockSize = `${evt.target.value}vh`;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.