I try to use flex layout to make a login content, it's just like an icon and an input in one row. I set width:20px and height:20px with icon and width:100% of input. I think it will make input to cover all the rest width except the specific value. The result is the size of icon changed.
With further learning about flex, I know another ways to achieve, such as flex:1 with input or setting min-width/height of icon, but I just want to know why the width:100% affect size of sibling icon.
.parent {
width: 72%;
height: 100px;
border: 1px solid lightblue;
display: flex;
align-items: center;
}
.icon {
width: 20px;
height: 20px;
border: 2px solid green;
display: block;
}
.login {
width: 100%;
}
.login::placeholder {
width: 91px;
}
<div class="parent">
<div class="icon"></div>
<input class="login" placeholder="place input your invite code" />
</div>
In this case, the size of .icon became 23.33*24, both width and height changed.