The element center-content should adjust it's height accordingly to it's childs element, however if I used float:left
on one of it's childs such as the element leftContent, leftContent will contain 95% of its body outside the center-content. As the center-content height will not adjust to maintain the leftContent inside.
If I remove float:left
from leftContent the element center-content will adjust it's height to maintain the leftContent element inside. Why does the float:left
does that?
To simplify, I want two small box one float left another float right inside a big box. this big box should change its height accordingly to the childs.
HTML
#header, #footer, #content-wapper, section {
max-width: 100%;
margin: 0 auto;
text-align: center;
}
#leftContent{
display: inline-block;
width: 49%;
height: auto;
float: left;
}
input{
width: 98%;
height: 40px;
border: solid 1px gray;
background-color: white;
}
.center-content {
width: 960px;
max-width: 100%;
margin: 0 auto;
padding: 2vw 0 2vw 0;
background-color: #E8E8E8
}
<section class="center-content">
<div id="leftContent">
<a><input name="income" type="text" id="income0" placeholder="Main Applicant Annual Income"></a><br>
<a><input name="income" type="text" id="income1" placeholder="Main Applicant Any-other Income"></a><br>
<a><input name="income" type="text" id="income2" placeholder="Second Applicant Annual Income"></a><br>
<a><input name="income" type="text" id="income3" placeholder="Second Applicant Any-other Income"></a><br><br>
<a><button class="btnCal" onclick="calculateMort()">Calculator</button></a>
</div>
</section>