I'm trying to apply display:flex on this form and failing. The structure of the HTML cannot be changed and I can't for the life of me figure out how to go about it. The only way they all inline (including the button) is to apply flex on both the form and .form-fields. But when the form wraps, the button stays in the first row, while the input field for the last name goes into second.
What am I doing wrong? And what can I do with CSS only, without touching the HTML? Thank you!
form, .form-fields {
display: flex;
}
<div class="form">
<form>
<div class="form-body">
<ul class="form-fields">
<li class="form-field">
<div class="input-container">
<span class="name_first">
<input type="text" name="first_name" id="first_name" value="" placeholder="First Name *" required="">
</span>
<span class="name_last">
<input type="text" name="last_name" id="last_name" value="" placeholder="Last Name *" required="">
</span>
</div>
</li>
<!-- name and last name -->
<li class="form-field">
<div class="input-container">
<input name="email_address" id="email_address" type="email" value="" placeholder="Email *" required="">
</div>
</li>
<!-- email adress -->
<li class="form-field">
<div class="input-container">
<input name="phone_number" id="phone_number" type="tel" value="" placeholder="Phone *" required="">
</div>
</li>
<!-- phone -->
</ul>
<input name="action" type="hidden" value="Request an Info Sheet">
</div>
<div class="form-footer">
<button type="submit" class="form_button">
<span>Contact Us</span>
</button>
</div>
<!-- button -->
</form>
</div>