In this example, I want the label and input each to take up 50% of the parent div container. This should be able to achieve via either width or flex property. However, when I was doing the experiment to switch from "width" to "flex: 0 0 50%" the size of the parent container expands. Right now the sidebar size grows bigger than before. It got me wondering what leads to this size expansion even though the result still meets my need(label and input field each occupies 50% of the width of its container). Please take a look at the following CSS snippet:
.form__label {
flex: 0 0 50%;
font-size: 1.5rem;
font-weight: 600;
}
.form__input {
width: 50%;
/* flex: 0 0 50%;
min-width: 0; */
padding: 0.3rem 1.1rem;
font-family: inherit;
font-size: 1.4rem;
border: none;
border-radius: 3px;
background-color: var(--color-light--3);
transition: all 0.2s;
}