<form action="">
<fieldset>
<legend>Without Contents</legend>
<div class="control">
<label for="input">input:</label>
<input type="text" id="input" placeholder="input element">
</div>
<div class="control">
<label for="textarea">textarea:</label>
<textarea name="textarea" id="textarea" cols="30" rows="2"></textarea>
</div>
<div class="control">
<label for="select">select:</label>
<select name="select" id="select">
<optgroup label="Default">
<option value="opationA">optionA</option>
</optgroup>
<option value="optionB">optionB</option>
</select>
</div>
<div class="control">
<label for="checkbox">checkbox:</label>
<input type="checkbox" name="checkbox" id="checkbox">
checkbox
</div>
<div class="control">
<label for="radio">radio:</label>
<input type="radio" name="radio" id="radio">
radio
</div>
<div class="control">
<label for="range">range:</label>
<input type="range" name="range" id="range" min="0" max="50" value="25" step="1">
</div>
<div class="control">
<label for="submit">submit:</label>
<input type="submit" name="submit" id="submit">
</div>
<div class="control">
<button>button</button>
</div>
<div class="control">
<details>
<summary>Copying... </summary>
<dl>
<dt>Transfer rate:</dt>
<dd>452KB/s</dd>
<dt>Local filename:</dt>
<dd>/home/rpausch/raycd.m4v</dd>
</dl>
</details>
</div>
<div class="control">
<label for="meter">meter: </label>
<meter min="0" max="100" value="75" name="meter" id="meter"></meter>
</div>
<div class="control">
<label for="progerss">progress: </label>
<progress min="0" max="100" value="75" name="meter" id="meter"></progress>
</div>
</fieldset>
<fieldset class="contents">
<legend>With Contents</legend>
<div class="control">
<label for="input">input:</label>
<input type="text" id="input" placeholder="input element">
</div>
<div class="control">
<label for="textarea">textarea:</label>
<textarea name="textarea" id="textarea" cols="30" rows="2"></textarea>
</div>
<div class="control">
<label for="select">select:</label>
<select name="select" id="select">
<optgroup label="Default">
<option value="opationA">optionA</option>
</optgroup>
<option value="optionB">optionB</option>
</select>
</div>
<div class="control">
<label for="checkbox">checkbox:</label>
<input type="checkbox" name="checkbox" id="checkbox">
checkbox
</div>
<div class="control">
<label for="radio">radio:</label>
<input type="radio" name="radio" id="radio">
radio
</div>
<div class="control">
<label for="range">range:</label>
<input type="range" name="range" id="range" min="0" max="50" value="25" step="1">
</div>
<div class="control">
<label for="submit">submit:</label>
<input type="submit" name="submit" id="submit">
</div>
<div class="control">
<button>button</button>
</div>
<div class="control">
<details>
<summary>Copying... </summary>
<dl>
<dt>Transfer rate:</dt>
<dd>452KB/s</dd>
<dt>Local filename:</dt>
<dd>/home/rpausch/raycd.m4v</dd>
</dl>
</details>
</div>
<div class="control">
<label for="meter">meter: </label>
<meter min="0" max="100" value="75" name="meter" id="meter"></meter>
</div>
<div class="control">
<label for="progerss">progress: </label>
<progress min="0" max="100" value="75" name="meter" id="meter"></progress>
</div>
</fieldset>
</form>
<div class="form">
<span>display:</span>
<label for="initial">
<input type="radio" id="initial" name="display" value="initial" checked />
initial
</label>
<label for="contents">
<input type="radio" id="contents" name="display" value="contents" />
contents
</label>
<label for="none">
<input type="radio" id="none" name="display" value="none" />
none
</label>
</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;
font-family: "Exo", Arial, sans-serif;
background-color: #557;
padding: 2rem 0;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 20px;
}
form {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
gap: 20px;
width: 100%;
max-width: 60vw;
font-size: 16px;
}
fieldset {
padding: 10px;
}
.control {
display: flex;
alig-items: center;
gap: 10px;
}
.control + .control {
margin-top: 16px;
}
.form {
display: flex;
justify-content: center;
gap: 10px;
font-size: 1.5rem;
}
.form label {
display: inline-flex;
align-items: center;
gap: 5px;
}
.form input {
width: 18px;
height: 18px;
}
.contents,
.contents legend,
.contents label,
.contents input,
.contents select,
.contents button,
.contents details,
.contents summary,
.contents meter,
.contents progress {
display: var(--display, initial);
}
const rootEle = document.documentElement;
const inputs = document.querySelectorAll('input[type="radio"]');
inputs.forEach((input) => {
input.addEventListener("click", (etv) => {
rootEle.style.setProperty("--display", etv.target.value);
});
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.