JSFiddle - React, Tailwind, and code Playground
by 7_Paul_21
HTML
<div class="form-section">
<h1 class="form-title">Play with the form!</h1>
<p>(Or read how this demo was made <a href="https://www.silocreativo.com/en/progressive-disclosure-with-css/" target="_blank">here</a>)</p>
<form id="form" class="form" autocomplete="off">
<input id="name" placeholder="Name *" name="name" type="text" value="" pattern="^[^0-9]+$" size="30" maxlength="245" autocomplete="nope" required>
<label for="name">Name</label>
<input id="surname" placeholder="Surname *" name="surname" type="text" value="" size="30" maxlength="245" autocomplete="nope" required>
<label for="surname">Surname</label>
<input id="email" placeholder="Email *" name="email" type="email" value="" size="30" maxlength="100" aria-describedby="email-notes" autocomplete="nope" required>
<label for="email">Email</label>
<textarea textarea="" placeholder="Comment *" id="comment" name="comment" cols="45" rows="8" maxlength="65525" required></textarea>
<label for="comment" data-help="Escribe algo! Lo primero que se te ocurra">Comment</label>
<input name="submit" type="submit" id="submit" class="submit" value="Post Comment">
</form>
</div>
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html, button, input, select, textarea {
font-family: 'Source Sans Pro', Helvetica, sans-serif;
background: #fffee9;
color: #6bccb4;
}
button, input, select, textarea {
font-size: 100%;
margin: 0;
max-width: 100%;
vertical-align: baseline;
}
textarea, input {
outline: none;
}
textarea {
overflow: auto;
vertical-align: top;
}
/* Layout Stuff */
.form-section {
width: 100%;
max-width: 400px;
margin: 30px auto;
}
h1 {
padding: 15px 0 0;
margin: 0;
text-align: center;
color: #6bccb4;
}
p {
text-align: center;
color: #6bccb4;
}
p a {
color: #6bccb4;
}
#form {
display: grid;
grid-template: auto / auto;
}
#form > input,
#form > textarea {
position: relative;
min-height: 1px;
padding: 15px;
width: 100%;
}
/* Form Stuff */
#form input[type="text"], #form input[type="email"], #form input[type="url"], #form textarea {
background-color: transparent;
border: 0;
border-bottom: 3px solid #6bccb4;
padding: 24px 10px 12px;
font-size: 20px;
font-size: 1.25rem;
margin: 10px auto;
color: #666
}
input[type="text"], input[type="email"], input[type="url"], textarea {
background-color: #fff;
padding: 24px 10px 12px;
font-size: 16px;
font-size: 1rem;
width: 100%;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
:focus {
outline: 0;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, textarea:focus {
background-color: #fff;
}
/* Order styles */
#form > :nth-child(1) {
order: 2;
}
#form > :nth-child(2) {
order: 1;
}
#form > :nth-child(3) {
order: 4;
}
#form > :nth-child(4) {
order: 3;
}
#form > :nth-child(5) {
order: 6;
}
#form > :nth-child(6) {
order: 5;
}
#form >...