I would like for the form below to have a fixed width and when a user clicks on the input box, this input box should expand and the other input boxes should shrink but the overall column width of the form should always remain constant.
Same behavior, if the user clicks on the other input boxes.
Is this possible with CSS and Flexbox or some Javascript is required?
Here is a fiddle and a snippet with and example:
#testForm {
padding: 0;
display: flex;
max-width: 600px;
}
#input1 {
background: red;
transition: all .5s ease;
}
#input2 {
background: blue;
transition: all .5s ease;
}
#input1:focus {
flex: 1 1 auto;
}
#input2:focus {
flex: 1 1 auto;
}
<form id="testForm">
<input type="text" id="input1">
<input type="text" id="input2">
</form>