I've created a contact form using a CSS grid layout that has 4 input fields and a submit button over 2 columns.
2 of the input fields are 1fr and 2 input fields are 1/3 wide. I'm trying to center the submit button below the input fields. I've attached a screenshot o my figma design so you can see how I'm trying to position my submit button.
After reading a few answers on stack overflow it seems that to use justify-content: center on the submit button I need to create a div container within the form that spans all columns 1/3 to place the button within. Then apparenly justify-content: center can be used. I've done this as other answers have suggested but I still can't get it working.
Does anyone know where I'm going wrong?
/* Homepage Contact Form */
.container-form {
max-width: 120rem;
margin: 0 auto;
padding: 0 1.5rem;
padding-bottom: 2rem;
}
.homepage-contact {
align-items: center;
justify-content: center;
text-align: center;
max-width: 70rem;
padding-top: 13rem;
}
.contact-message {
font-size: 1.8rem;
margin-bottom: 2rem;
font-family: 'Raleway', sans-serif;
line-height: 3rem;
}
.home-contact-form form {
display: grid;
grid-template-columns: 1fr 1fr;
margin: 0 auto;
max-width: 90rem;
}
.home-contact-form form p {
margin: 0.8rem;
}
.home-contact-form form .full {
grid-column: 1 / 3;
}
.contact-btn-container {
grid-column: 1/ 3;
justify-content: center;
}
.home-contact-form form input {
height: 4rem;
}
.home-contact-form form input,
.home-contact-form form textarea,
home-contact-form {
width: 100%;
}
input {
padding-left: 1.5rem;
}
textarea {
padding-left: 1.5rem;
}
<!-- Homepage contact start -->
<section class="homepage-contact container-form">
<div class="homepage-contact-text">
<h2 class="title contact-title">Lets Discuss Your Project</h2>
<p class="contact-message">We’re always happy to discuss your project with you and put together a free proposal, just fill out the form below or give us a call to get started</p>
</div>
</section>
<div class="home-contact-container">
<div class="home-contact-form">
<form action="">
<p class="full">
<input type="text" name="name" placeholder="Name">
</p>
<p>
<input type="email" name="email" placeholder="Email">
</p>
<p>
<input type="text" name="phone" placeholder="Phone">
</p>
<p class="full">
<textarea name="message" placeholder="Message" rows="15"></textarea>
</p>
<div class="contact-btn-container">
<p>
<button class="contact-btn">Submit</button>
</p>
</div>
</form>
</div>
</div>