I can't seem to wrap my head around what's happening here. I've got an HTML layout with a header, sidebar, and central content page.
Both the sidebar and central content are within the same div acting as a clearfix. I floated the sidebar left and the content right, but instead of aligning neatly, the content div just drops down.
Markup
<body>
<header>
<img src="./img/Logo_Color.png" alt="Logo">
<h1>Batch Documentation</h1>
</header>
<div class="clearfix">
<div class="sidebar">
<nav>
<ul>
<li><a href="#">Overview</a></li>
<li><a href="#">Fl Overview</a></li>
<li><a href="#">PF2 Overview</a></li>
<li><a href="#">Inputs</a></li>
<li><a href="#">Outputs</a></li>
<li><a href="#">Appendix A</a></li>
<li><a href="#">Appendix B</a></li>
</ul>
</nav>
</div>
<main>
<div class="centerContent">
<h2>Overview</h2>
<p>
Integer in qui primam te ipsa-plenus Crescere Effectum Septembrem. Me quo 700% octavas ad imperium caduca si eros eius orci arcu te mirum consumere, meritos modo diam eros ti, in cras diuturna interpres, semente, securitas sem odio dignitatis reuiescat.
Lius quam charybdium nonullis sem inibunt illum, civibus eius arendom, Indolem te e licentiose te maiestatem molestias typi combinatur sagittis successus nomine, reniam eos te-feroces assueverunt.
Saepe non, Fervore 2000 galliae nibh eu ea ut:
</p>
<code>Hello</code>
</div>
</main>
</div>
</body>
CSS
* {
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
margin: 0;
padding: 0;
list-style-type: none;
}
body {
margin: auto;
width: 1265px;
background-color: #eae0ff;
}
main {
display: inline-block
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
header {
margin: 15px 10px 20px 10px;
}
.sidebar {
width: 25%;
margin: 5px 0px 10px 10px;
padding-right: 20px;
float: left;
background-color: #ccccff;
}
.centerContent {
width: 75%;
margin: auto;
padding-left: 20px;
border: 3px solid #73ad21;
float: right;
}
li {
margin-top: 5px;
margin-bottom: 5px;
}
code {
width: 90%;
font-family: 'Source Code Pro', monospace;
color: #43892a;
background-color: #000;
display: block;
}
It's bothering me that even though I've set the box sizing to border box and display to inline-block, there seems to be some issues with how the widths are being calculated for the sidebar (25%) and main content (75%), taking margins and paddings into account separately rather than inclusively.