I'm having trouble stopping my divs extending beyond the parent div when I add a margin. In the example below I've made the divs width 100%, then added margin-left: 32px; to the second div.
I want it to stay within the 100% width, but the margin-left seems to push it outside the parent div.
.parent {
flex-direction: column;
width: 100%;
max-width: 540px;
padding-right: 32px;
padding-left: 32px;
margin-right: auto;
margin-left: auto;
overflow: auto;
float: none;
}
.child-1 {
position: relative;
width: 100%;
background-color: blue;
}
.child-2 {
padding-right: 15px;
position: relative;
padding-left: 15px;
margin-left: 32px;
width: 100%;
background-color: yellow;
}
#parent-box {
background-color: red;
}
<div class="parent" id="parent-box">
<div class="child-1"><p>test</p></div>
<div class="child-2"><p>test box</p></div>
</div>