<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>
/* General Styles */
* {
    -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 > :nth-child(7) {
  order: 8;
}
#form > :nth-child(8) {
  order: 7;
}
#form > :nth-child(9) {
  order: 9;
}
/* Label styles */
#form label {
    padding: 5px 0;
    font-size: 0;
    display: block;
    opacity: 0;
    height: 16px;
}
#form input:focus + label,
#form textarea:focus + label {
    opacity: 1;
}
#form input:invalid,
#form textarea:invalid {
    border-bottom: 3px solid #F9D5C7;
    background-color: #F9D5C7;
}
#form input:focus:invalid,
#form textarea:focus:invalid {
    background-color: transparent;
    border-bottom: 3px solid #eb7e7f;
}
#form input:invalid + label,
#form textarea:invalid + label {
    color: #b92326;
}
#form input:invalid + label,
#form textarea:invalid + label {
    color: #b92326;
}
#form input:focus + label:after,
#form textarea:focus + label:after {
    content: "";
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #d8d8d8 0%,#d8d8d8 24%,transparent 24%,transparent 25%,#d8d8d8 25%,#d8d8d8 49%,transparent 49%,transparent 50%,#d8d8d8 50%, #d8d8d8 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
    display: block;
    margin: 0 auto;
}
#form input:nth-of-type(1):focus:invalid + label:after {
    background: linear-gradient(to right, #eb7e7f 0%,#eb7e7f 24%,transparent 24%,transparent 25%,#d8d8d8 25%,#d8d8d8 49%,transparent 49%,transparent 50%,#d8d8d8 50%, #d8d8d8 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form input:nth-of-type(1):focus:valid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#d8d8d8 25%,#d8d8d8 49%,transparent 49%,transparent 50%,#d8d8d8 50%, #d8d8d8 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form input:nth-of-type(2):focus:invalid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#eb7e7f 25%,#eb7e7f 49%,transparent 49%,transparent 50%,#d8d8d8 50%, #d8d8d8 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form input:nth-of-type(2):focus:valid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#6bccb4 25%,#6bccb4 49%,transparent 49%,transparent 50%,#d8d8d8 50%, #d8d8d8 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form input:nth-of-type(3):focus:invalid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#6bccb4 25%,#6bccb4 49%,transparent 49%,transparent 50%,#eb7e7f 50%, #eb7e7f 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form input:nth-of-type(3):focus:valid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#6bccb4 25%,#6bccb4 49%,transparent 49%,transparent 50%,#6bccb4 50%, #6bccb4 74%,transparent 74%,transparent 75%,#d8d8d8 75%,#d8d8d8 100%);
}
#form textarea:focus:invalid + label:after {
    background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#6bccb4 25%,#6bccb4 49%,transparent 49%,transparent 50%,#6bccb4 50%, #6bccb4 74%,transparent 74%,transparent 75%,#eb7e7f  75%,#eb7e7f 100%);
}
#form textarea:focus:valid + label:after {
   background: linear-gradient(to right, #6bccb4 0%,#6bccb4 24%,transparent 24%,transparent 25%,#6bccb4 25%,#6bccb4 49%,transparent 49%,transparent 50%,#6bccb4 50%, #6bccb4 74%,transparent 74%,transparent 75%,#6bccb4  75%,#6bccb4 100%);
}
#form input:valid,
#form textarea:valid {
    border-bottom: 3px solid #C9EDD6;
    background-color: #C9EDD6;
}
#form input:focus:valid,
#form textarea:focus:valid {
    border-bottom: 3px solid #6bccb4;
    background-color: transparent;
}
#form input:valid + label,
#form textarea:valid + label {
    color: #8BC34A;
}
#form input:placeholder-shown,
#form textarea:placeholder-shown {
    background-color: transparent;
    border: 0;
    border-bottom: 3px solid #d8d8d8;
}
#form input::placeholder,
#form textarea::placeholder {
    color: #d8d8d8;
}
#form input::-webkit-input-placeholder,
#form textarea::-webkit-input-placeholder {
    color: #d8d8d8;
}
#form input:-ms-input-placeholder,
#form textarea:-ms-input-placeholder {
    color: #d8d8d8;
}
#form input::-moz-placeholder,
#form textarea::-moz-placeholder {
    color: #d8d8d8;
}
#form input:focus::placeholder,
#form textarea:focus::placeholder {
    color: transparent;
}
#form input:focus::-webkit-input-placeholder,
#form textarea:focus::-webkit-input-placeholder {
    color: transparent;
}
#form input:focus:-ms-input-placeholder,
#form textarea:focus:-ms-input-placeholder {
    color: transparent;
}
#form input:focus::-moz-placeholder,
#form textarea:focus::-moz-placeholder {
    color: transparent;
}
#form input[type="submit"] {
    background-color: transparent;
    border: 3px solid #6bccb4;
    color: #6bccb4;
    padding: 5px 15px;
    font-size: 20px;
    font-size: 1.25rem;
    margin: 10px auto;
    vertical-align: middle;
    cursor: pointer;
}
#form input[type="submit"]:hover {
    background-color: #C9EDD6;
    border: 3px solid #C9EDD6;
}

/* UX Progressive disclosure */
#form > * {
  display: none;
}
#form > input:first-of-type {
  display: block;
}
#form input:valid + label + input,
#form input:valid + label + textarea,
#form textarea:valid + label + input,
#form textarea:valid + label + textarea {
    display: block;
}
// Nothing to do here
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.