I have a <form> inside of a <div>
<div>
<form></form>
</div>
I want the <form> to take up 100% of the parent width taking into account margin and padding. I achieve this by setting box-sizing: border-box
div {
display: flex;
align-items: center;
justify-content: center;
}
form {
box-sizing: border-box;
width: 100%;
margin: 50px;
}
This works. However, in my use case I need the parent div to have flex-direction: column, as <form> will have a sibling <section> above it,
<div>
<section></section>
<form></form>
</div>
div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
form {
box-sizing: border-box;
width: 100%;
margin: 50px;
}
This breaks the desired behavior. The <form> now takes up 100% of the horizontal space, and margin goes outside of it's parent boundary.
This is the desired effect
