<header>
<div class="control">
<label for="ending-shape">ending-shape:</label>
<select name="ending-shape" id="ending-shape">
<option value="" selected></option>
<option value="circle">circle</option>
<option value="ellipse">ellipse</option>
</select>
</div>
<div class="control">
<label for="size">size:</label>
<select name="size" id="size">
<optgroup label="extent-keyword">
<option value="farthest-corner" selected>farthest-corner</option>
<option value="farthest-side">farthest-side</option>
<option value="closest-side">closest-side</option>
<option value="closest-corner">closest-corner</option>
</optgroup>
<optgroup label="length for circle" id="circle">
<option value="10px">10px</option>
<option value="10em">10em</option>
<option value="10rem">10rem</option>
<option value="10vw">10vw</option>
<option value="10vh">10vh</option>
</optgroup>
<optgroup label="length-percentage for ellips" id="ellipse">
<option value="10% 20%">10% 20%</option>
<option value="20% 10%">20% 10%</option>
<option value="50% 50%">50% 50%</option>
</optgroup>
</select>
</div>
<div class="control">
<label for="position">position:</label>
<select name="position" id="position">
<optgroup label="bg-position">
<option value="top">top</option>
<option value="right">right</option>
<option value="bottom">bottom</option>
<option value="left">left</option>
<option value="center" selected>center</option>
<option value="top left">top left</option>
<option value="top center">top center</option>
<option value="top right">top right</option>
<option value="center center">center center</option>
<option value="center right">center right</option>
<option value="left center">let center</option>
<option value="bottom left">bottom left</option>
<option value="bottom center">bottom center</option>
<option value="bottom right">bottom right</option>
</optgroup>
<optgroup label="length-percentage">
<option value="10px 50px">10px 50px</option>
<option value="10em 50em">10em 50em</option>
<option value="10rem 50rem">10rem 50rem</option>
<option value="10vw 50vw">10vw 50vw</option>
<option value="10vh 50vh">10vh 50vh</option>
<option value="10% 50%">10% 50%</option>
<option value="10%">10%</option>
<option value="10px 50%">10px 50%</option>
<option value="10% 50px">10% 50px</option>
</optgroup>
</select>
</div>
</header>
<div class="container">
<div class="radial__gradient"></div>
<div class="radial__gradient"></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: grid;
grid-template-rows: 100px 1fr;
font-family: "Exo", Arial, sans-serif;
background-color: #222;
}
header {
background-color: rgba(0, 0, 0, 0.85);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
.control {
margin: 0 5px;
display: flex;
align-items: center;
font-size: 1.2rem;
}
:root {
--color-start: #ebf;
--color-center: #09f;
--color-end: #f36;
--ending-shape: ;
--size: farthest-corner;
--position: center;
}
.container {
display: grid;
padding: 10px;
grid-template-columns: 50vh 1fr;
gap: 10px;
place-content: center;
}
.radial__gradient {
border-radius: 5px;
min-height: 50vh;
background-image: radial-gradient(
var(--ending-shape) var(--size) at var(--position),
var(--color-start),
var(--color-center),
var(--color-end)
);
}
const selects = document.querySelectorAll("select");
const rootElement = document.documentElement;
const circleOpt = document.getElementById("circle");
const ellipsOpt = document.getElementById("ellipse");
selects.forEach((select) =>
select.addEventListener("change", (e) => {
if (e.target.value === "circle" || e.target.value === "") {
ellipsOpt.setAttribute("disabled", true);
circleOpt.removeAttribute("disabled");
rootElement.style.setProperty(`--${e.target.id}`, e.target.value);
} else if (e.target.value === "ellipse") {
ellipsOpt.removeAttribute("disabled");
circleOpt.setAttribute("disabled", true);
rootElement.style.setProperty(`--${e.target.id}`, e.target.value);
} else {
rootElement.style.setProperty(`--${e.target.id}`, e.target.value);
}
// 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.