<h1>Subgrid Forms</h1>
<form action="">
<label for="name" class="field">
<span class="label-text">Full Name (Örn: Ali Veli)</span>
<input type="text" id="name">
</label>
<label for="email" class="field">
<span class="label-text">Email</span>
<input type="email" id="email">
</label>
<label for="message" class="field">
<span class="label-text">Longer</span>
<textarea name="" id="message"></textarea>
</label>
<button>send!</button>
</form>
form {
display: grid;
grid-template-columns: max-content 1fr;
margin-bottom: 1em;
gap: 1.2em;
}
/* Subgrid */
.field {
grid-column: span 2;
display: grid;
grid-template-columns: subgrid;
}
/* Styles */
html {
--light: 1;
--dark: -1;
--mode: var(--demo-mode, var(--os-mode, 1));
--unmode: calc(var(--mode) * -1);
--zero: calc((var(--mode) + 1) / 2);
--unzero: calc((var(--unmode) + 1) / 2);
/* fonts */
--zilla: 'Zilla Slab', serif;
--zilla-highlight: 'Zilla Slab Highlight', serif;
--inter: 'Inter', sans-serif;
/* primary colors */
--neon-blue: #00ffff;
--lemon-yellow: #fff44f;
--warm-red: #ff4f5e;
--neon-green: #54ffbd;
--dark-purple: #6e008b;
/* secondary colors */
--dark-green: #005e5e;
--dark-blue: #00458b;
--dark-grey: #959595;
--light-grey: #e7e5e2;
/* main color usage */
--background: hsl(0deg, 100%, calc(100% * var(--mode)));
--color: hsl(0deg, 100%, calc(100% * var(--unmode)));
--callout: hsla(0deg, 0%, 50%, 0.25);
/* action colors */
--action: hsl(
180deg,
50%,
calc((50% * var(--unzero)) + (18% * var(--zero)))
);
--hover: hsl(
180deg,
100%,
calc((50% * var(--unzero)) + (18% * var(--zero)))
);
/* sizes */
--font-scale: 0.5vmin;
--radius: 0.25em;
/* applied… */
background-color: var(--background);
color: var(--color);
font-family: var(--inter);
font-size: calc(1em + var(--font-scale));
line-height: 1.4;
}
@media (prefers-color-scheme: dark) {
html {
--os-mode: -1;
}
}
/* Reset */
* { box-sizing: border-box; }
body {
align-content: center;
background-color: var(--neon-blue);
display: grid;
grid-gap: 1em;
justify-content: center;
min-height: 100vh;
margin: 0;
padding: 1em;
}
@media (prefers-color-scheme: dark) {
body {
background-color: var(--dark-blue);
}
}
h1 {
grid-column: 1 / -1;
}
form {
width: 80vw;
max-width: 30em;
}
input[type=text],
input[type=email],
textarea {
background: var(--callout);
border: 2px solid var(--action);
border-radius: 0 var(--radius);
color: var(--color);
font-family: var(--zilla);
padding: 0.25em;
}
input[type=text]:focus,
input[type=email]:focus,
textarea:focus {
border-color: var(--hover);
}
textarea {
min-height: 6em;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.