Why aren't my divs side by side in the block layout with floats? From what I understand, block layout takes up the whole width (I tried inline-block and inline as well but didn't work as expected, display:flex works though). But with float I believe it gets out of the block and collapses the parents height (for which I used clear). Just wanted to know how to get these divs side by side using floats.
.row {
max-width: 1440px;
margin: 0 auto;
}
.row::after {
content: "";
display: table;
clear: both;
}
.col-1-2 {
background-color: red;
width: calc((100%-50px)/2);
float: left;
}
.col-1-2:not(last-child) {
margin-right: 50px;
}
<body>
<div class="row">
<div class="col-1-2"> col 1 of 2</div>
<div class="col-1-2"> col 1 of 2</div>
</div>
</body>