I am trying to create stacked inputs using flexbox, with the additional ability to also set rows. Here is the code:
.stacked-inputs,
.stacked-inputs .row {
display: -ms-flexbox;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
-ms-flex-align: center;
align-items: center;
}
.stacked-inputs .row {
width: 100%;
margin-bottom: 10px;
}
.stacked-inputs > input,
.stacked-inputs .row > input {
position: relative;
-ms-flex: 1 1 0%;
flex: 1 1 0%;
min-width: 0;
}
<div class="stacked-inputs">
<input type="text" placeholder="First name">
<input type="text" placeholder="Last name">
</div>
<br /><br />
<div class="stacked-inputs">
<div class="row">
<input type="text" placeholder="First name">
<input type="text" placeholder="Last name">
</div>
<div class="row">
<input type="text" placeholder="Job title">
<input type="text" placeholder="Year started">
</div>
</div>
When inputs are stacked without using rows, they will all be stacked horizontally. However, if a row is used, then obviously the rows of stacked inputs can be divided up nicely. Would love a review of this code from someone. Thanks in advance.