<div class="box"></div>
<div class="actions">
<div class="control">
<label for="border-radius">border-radius:</label>
<input type="range" id="border-radius" min="0" max="100" value="50" step="1" />
<output data-border-radius>50px</output>
</div>
<div class="control">
<label for="border-width">border-width:</label>
<input type="range" id="border-width" min="0" max="100" value="50" step="1" />
<output data-border-width>50px</output>
</div>
<div class="control">
<label for="padding">padding:</label>
<input type="range" id="padding" min="0" max="100" value="50" step="1" />
<output data-padding>50px</output>
</div>
<ul>
<li>border</li>
<li>padding</li>
<li>content</li>
</ul>
</div>
body {
background-color: #1d1e1f;
width: 100vw;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
:root {
--border-radius: 50px;
--border-width: 30px;
--padding: 30px;
}
.box {
margin: 5px;
width: 480px;
height: 480px;
box-sizing: border-box;
background-image: linear-gradient(134deg, #3023ae 0%, #c86dd7 100%),
linear-gradient(134deg, #f36 0%, #f63 100%);
background-origin: padding-box;
background-clip: content-box, padding-box;
border-radius: var(--border-radius);
border: var(--border-width) solid #f90;
padding: var(--padding);
}
.actions {
display: flex;
flex-direction: column;
color: #fff;
font-size: 1.5rem;
}
.control {
display: flex;
align-items: center;
margin-bottom: 10px;
}
label {
min-width: 200px;
text-align: right;
margin-right: 10px;
}
ul {
margin: 20px 0 0;
padding: 0;
list-style: none outside none;
display: flex;
flex-direction: column;
}
li {
display: flex;
align-items: center;
text-align: right;
max-width: 200px;
margin-bottom: 10px;
justify-content: flex-end;
}
li::before {
content: "";
display: inline-block;
width: 16px;
height: 16px;
border-radius: 50%;
margin-right: 10px;
}
li:nth-child(1)::before {
background: #f90;
}
li:nth-child(2)::before {
background: linear-gradient(134deg, #f36 0%, #f63 100%);
}
li:nth-child(3)::before {
background: linear-gradient(134deg, #3023ae 0%, #c86dd7 100%);
}
output {
margin-left: 5px;
}
const inputs = document.querySelectorAll("input");
const documentElement = document.documentElement;
inputs.forEach((item, index) => {
item.addEventListener("change", (etv) => {
documentElement.style.setProperty(
`--${etv.target.id}`,
`${etv.target.value}px`
);
document.querySelector(
`output[data-${etv.target.id}]`
).textContent = `${etv.target.value}px`;
});
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.