<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;800&display=swap" rel="stylesheet"><div class="select-flex">
<select id="select-5">
<option value="align-content: flex-start;">flex-start</option>
<option value="align-content: flex-end;"">flex-end</option>
<option value="align-content: center;">center</option>
<option value="align-content: space-between;">space-between</option>
<option value="align-content: space-around;">space-around</option>
</select>
</div>
<div class="example-flex container" data-id="select-5">
<div style="width: 64px;" class="miniature-box">1</div>
<div style="width: 48px;" class="miniature-box">2</div>
<div style="width: 32px;" class="miniature-box">3</div>
<div style="width: 64px;" class="miniature-box">4</div>
<div style="width: 128px;" class="miniature-box">5</div>
<div style="width: 64px;" class="miniature-box">6</div>
<div style="width: 32px;" class="miniature-box">7</div>
<div style="width: 128px;" class="miniature-box">8</div>
</div>
<pre><code class="css" data-id="select-5">
.container {
align-content: flex-start
}
</code></pre>
body {
background: rgb(15 19 22);
color: white;
padding: 1rem 2rem;
font-family: Inter, sans-serif;
}
h2 {
font-variation-settings: "wght" 800;
font-size: 1.75rem;
flex-direction: row-reverse;
display: flex;
justify-content: flex-end;
align-items: center;
color: #ffb834;
}
p {
font-size: 1.25rem;
line-height: 2.5rem;
margin-bottom: 2rem;
text-decoration: none;
color: #ffffffd9;
max-width: 100%;
}
.example-flex {
display: flex;
padding: 0.5rem;
margin: 1rem 0;
background: #191f2b;
border-radius: 14px;
flex-wrap: wrap;
}
.miniature-box {
width: 64px;
height: 32px;
border-radius: 10px;
background: linear-gradient(45deg,#4d59ff,#0037ff);
/* box-shadow: inset 0 2px #ffffff17, 0 2px 8px rgb(0 0 0 / 30%); */
margin: 0.5rem;
transition: all .2s ease-out;
text-align: center;
font-size: 1.25rem;
line-height: 2rem;
font-variation-settings: 'wght' 600;
color: rgba(255,255,255,.5);
}
.highlighted {
background: linear-gradient(45deg, #ff7600, #ffeb00);
order: 0;
color: rgba(0,0,0,0.6);
transform: scale(1.1);
}
.select-option + h3 {
margin: 1rem 0 0 0;
font-size: 1rem !important;
}
.select-option {
padding: 0.5rem 0;
float: left;
width: 100%;
display: flex;
margin: 0 0 0.5rem 0;
align-items: center;
}
.select-option p {
margin: 0 1rem 0 0;
min-width: 160px;
background: #121d357d;
padding: 0 0 0 0.75rem;
}
.select-option p {
position: relative;
z-index: 999;
border-radius: 6px 0 0 6px;
font-family: Inter, sans-serif;
margin: 0 1rem 0 0;
line-height: 2.5rem;
background: #191f2b!important;
min-width: 160px;
padding: 0 0 0 0.75rem;
}
.container {
height: 300px;
align-content: flex-start;
}
.select-option p {
margin: 0 1rem 0 0;
min-width: 160px;
background: #121d357d;
padding: 0 0 0 0.75rem;
}
.select-option select {
margin-left: -1.75rem;
background: #2a3240;
border-radius: 0 6px 6px;
padding-left: 2rem;
color: white;
text-transform: none;
border: 1px solid #2b3240;
}
select {
border: none;
border-radius: 10px;
padding: 0.5rem;
font-family: Inter,sans-serif;
background: #2f384a;
color: #fff;
text-transform: none;
font-size: 1rem;
font-variation-settings: "wght" 500;
max-width: 400px;
}
.html-css-pair pre:first-of-type code {
border-radius: 14px 0 0 14px;
}
.html-css-pair pre:first-of-type code {
border: none;
margin-top: 0;
border-radius: 14px 0 0 14px;
border-right: 1px solid #2e333e;
}
.html-css-pair pre:last-of-type code {
border: none;
margin-top: 0;
border-radius: 0 14px 14px 0;
}
.plain-code, pre code {
font-family: Menlo,Monaco,Courier New,monospace;
left: 5px;
margin-top: 0;
overflow: auto;
box-sizing: border-box;
padding: 0 1.5rem 6.5rem;
display: block;
max-height: 500px;
line-height: 1.5rem;
border-radius: 10px;
margin-bottom: 2rem;
width: 100%;
float: left;
background: #191f2b;
font-size: 1rem;
max-width: 100%;
}
.html-css-pair pre {
flex-grow: 1;
max-width: 50%;
margin-bottom: 0;
}
.html-css-pair {
display: flex;
width: calc(100% - 0rem);
overflow: visible;
border-radius: 10px;
border-radius: 8px;
overflow: hidden;
}.select-option+h3 {
margin: 1rem 0 0 0;
font-size: 1rem!important;
}
document.addEventListener('DOMContentLoaded', function(e) {
document.querySelectorAll('select').forEach(function(item) {
item.addEventListener('change', function(e) {
if(item.classList.contains('main-selector') || item.classList.contains('main-selector-item')) {
let thisId = item.getAttribute('data-id');
let css = `
display: flex;
flex-wrap: wrap;`;
let itemCss = '';
document.querySelectorAll('.main-selector').forEach(function(item) {
css += `
${item.value}`;
});
document.querySelectorAll('.main-selector-item').forEach(function(item) {
itemCss += `
${item.value}`;
});
document.querySelector(`.example-flex[data-id="${thisId}"]`).setAttribute('style', css);
document.querySelectorAll(`.example-flex[data-id="${thisId}"] > div`).forEach(function(item) {
let newStyle = item.getAttribute('style') + itemCss;
item.setAttribute('style', newStyle);
})
document.querySelector(`code[data-id="${thisId}"]`).textContent = `
.container {${css}
}`;
document.querySelector(`.items code[data-id="${thisId}"]`).textContent = `
.item {${itemCss}
}`;
}
else if(item.classList.contains('item-selector')) {
let thisId = item.getAttribute('id');
let thisValue = this.value;
document.querySelector(`code[data-id="${thisId}"]`).textContent = `
.item {
${thisValue}
}`;
document.querySelector(`.example-flex[data-id="${thisId}"] .highlighted`).setAttribute('style', thisValue);
}
else {
let thisId = item.getAttribute('id');
let thisValue = this.value;
document.querySelector(`code[data-id="${thisId}"]`).textContent = `
.container {
${thisValue}
}`;
document.querySelector(`.example-flex[data-id="${thisId}"]`).setAttribute('style', thisValue);
}
});
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.