I am relatively new to the world of html and css, trying my hand at constructing html layouts. I have encountered a bit of trouble in aligning the footer and section to the left of the nav bar. No matter what percentage widths I use, they always end up overlapping. Why does this keep happening?
body {
background: gray;
}
section {
background: red;
display: block;
width: 70%;
position: absolute;
top: 0;
right: 0;
}
footer {
background: green;
display: block;
width: 70%;
padding: 20px;
position: absolute;
bottom: 0;
right: 0;
}
nav {
display: block;
width: 30%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: blue;
color: #fff;
padding: 10px;
}
<body>
<nav class="sidebar">
<!-- Insert sidebar content here -->
Content example
</nav>
<section>
<!-- Insert section content here -->
Content example
</section>
</body>
<footer>
Content example
</footer>