I have created a contact form using HTML and CSS. Each input field has a small
tag below to display errors, causing the adjacent field to shift downward if an error occurs.
To view the live form, click here
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.form-fields {
display: -ms-grid;
display: grid;
grid-template-areas: 'name email' 'subject phone' 'message message';
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
grid-gap: 1rem;
}
.form-fields .input {
font-size: 0.875rem;
background: #f2f3f5;
border-color: #f2f3f5;
}
.form-fields .name-field {
-ms-grid-row: 1;
-ms-grid-column: 1;
grid-area: name;
}
.form-fields .email-field {
-ms-grid-row: 1;
-ms-grid-column: 2;
grid-area: email;
}
.form-fields .subject-field {
-ms-grid-row: 2;
-ms-grid-column: 1;
grid-area: subject;
}
.form-fields .phone-field {
-ms-grid-row: 2;
-ms-grid-column: 2;
grid-area: phone;
}
.form-fields .message-field {
-ms-grid-row: 3;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-area: message;
}
.form-fields .message-field .input {
height: 120px;
}
<div class="form-fields">
<div class="form-group name-field">
<input type="text" name="name" placeholder="Your Name" id="name" class="input form-control" />
<small class="text-danger">some error for this input</small>
</div>
<div class="form-group email-field">
<input type="text" name="email" placeholder="Email Address" id="email" class="input form-control" />
<small class="text-danger"></small>
</div>
<div class="form-group subject-field">
<input type="text" name="subject" placeholder="Subject" id="subject" class="input form-control" />
<small class="text-danger"></small>
</div>
<div class="form-group phone-field">
<input type="text" name="phone" placeholder="Phone" id="phone" class="input form-control" />
<small class="text-danger"></small>
</div>
<div class="form-group message-field">
<textarea name="message" placeholder="Message" id="message" class="input form-control"></textarea>
<small class="text-danger"></small>
</div>
</div>
Is there a way to resolve this issue?