I’m trying to make a contact form and I wanted to get both first name and last name. I know an easier solution would be just make 1 input for full name but I didn’t want to do that. Something similar to this image here, but I can figure it out and I’m really out of clue how to do it. Please help! Thank you!
HTML:
<section id="contact-form">
<form method="POST" action="#">
<h3>You can either contact me via these channels or fill in the form below</h3>
<ul id="contact-list">
<li>
<a href="#" target="_blank" rel="noopener" aria-label="Message me on WhatsApp (Open in a new tab)"><i class="fa-brands fa-whatsapp"></i>
+1234567890</a>
</li>
<li>
<a href="#" target="_blank" rel="noopener" aria-label="Send me an email (Open in a new tab)"><i class="fa-regular fa-envelope"></i>
[email protected]</a>
</li>
</ul>
<label for="fname" class="names">First name:</label>
<label for="lname" class="names">Last name:</label>
<br>
<input type="text" name="first-name" id="fname" required>
<input type="text" name="last-name" id="lname" required>
<br>
<label for="email">Email:</label>
<br>
<input type="email" name="e-mail" id="email" required>
<br>
<label for="message">Your Massage:</label>
<br>
<textarea name="user-message" id="message" cols="30" rows="10" placeholder="Your message here ..."></textarea>
</form>
CSS:
form {
border: 3px solid #81a97b;
border-radius: 5px;
width: 50%;
margin: 0 auto;
height: 450px;
min-width: 320px;
text-align: center;
padding: 3em;
}
#contact-list li{
display: inline-block;
margin: 20px 12px;
}
#contact-list a{
color: #4d4d4d;
font-size: 130%;
}
input, textarea{
border: 1px solid #ffb30f
}
.names {
float:left;
margin-left: 103px;
}
#fname, #lname {
width: 40%;
margin: 5px 20px;
}
#email {
width: 100%;
}
textarea {
resize: none;
}
I tried display:inline-block; floatl:left, text-align:left;
and cant seem to get what I’m have in mind
2
Answers
Make use of css flexbox .
I used both Flexbox and Grids in this example. I hope it helps.