I am having trouble moving the button next to the h3 and email input. I want them all in line horizontally. I have tried a lot of different things to make it work. At first I was unable to edit the style of the button literally at all. Somehow I figured out how to edit the style but now I can’t move it back to be next to the email input.
.container {
display: inline-flex;
}
h3 {
font-size: 2vw;
margin: .5vw;
}
button {
border-style: solid;
border-color: #CCCCCC;
border-radius: 20px;
border-width: thin;
font-size: 1.25vw;
transition-duration: 0.4s;
cursor: pointer;
color: #CCCCCC;
text-align: center;
}
<main>
<h1>
XXXXX
</h1>
<h2>
coming soon
</h2>
<div class="container">
<h3>sign up for more</h3>
<form method="POST" netlify>
<div class="email">
<input type="email" name="email" id="email" placeholder="email" required>
</div>
<button type="submit" class="sign up">sign up</button>
</form>
</div>
</main>
3
Answers
Add this line of css
It can be solved in many ways. Also don’t give space between when you’re declaring a single class. use "signup"/"SignUp"/"signUp".
Add
display: flex
to theform
There are many ways to align them horizontally. You can use the
display: inline
property ordisplay: flex
property as well.Using inline:
Inline & Block elements
.Div’s are "block" elements by default, so they accomodate all the space in the line. Hence the other element breaks to the second line. But by using this property, you turn it into an "inline" element so it only takes necessary space and allows the button element to be displayed next to it.
Using Flexbox:
Flexbox can be used to align items enclosed within a container horizontally or vertically. Albeit, it could be complicated, but you could do much more with flexbox! But I assume you’d only need
display: inline
for now, to get your desired result.