У меня есть форма регистрации с 6 input
элементами внутри элемента form
, который представляет собой гибкий контейнер. flex-direction
- это column
в форме, поэтому все элементы input
отображаются по 1 в строке:
![enter image description here](https://i.stack.imgur.com/GkZdc.png)
Есть ли способ заставить отображать два элемента в строке, например:
![](https://i.stack.imgur.com/MyBLQ.png)
Я попытался установить flex-direction: row
и поставить
<div class="line-break"></div>
.line-break {
width: 100%;
}
после каждый элемент input
, но он не работал.
JSFiddle
form {
width: 100%;
height: 100%;
/*
border: 1px solid white;
*/
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/*
Just for style, nevermind it
*/
.form-input {
height: 20px;
width: 50%;
background-color: silver;
border-radius: 10px;
border: none;
padding: 6px;
margin: 15px;
}
<form action="/login">
<h2 class="form-title">Sing up</h2>
<input class="form-input" type="text" placeholder="First Name" name="firstname">
<div class="line-break"></div>
<input class="form-input" type="text" placeholder="Last Name" name="lastname">
<input class="form-input" type="text" placeholder="Email" name="email">
<input class="form-input" type="password" placeholder="Password" name="password">
<input class="form-input" type="password" placeholder="Confirm" name="confirm">
<input class="form-input" type="text" placeholder="Age" name="age">
</form>