I am trying to create a Side-navbar for a products section of my website. Whenever I create my navbar, the text gets pushed down underneath it. Any ideas?
body {
margin: 0;
}
.sidenav ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 15%;
background-color: #f1f1f1;
position: relative;
height: 75%;
overflow: auto;
}
.sidenav li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
<section>
<section class="sidenav">
<ul>
<li><a href="index.html"><b>HOME</b></a></li>
<li><a href="about.html">ABOUT</a></li>
<li><a href="shop.html">SHOP</a></li>
<li><a href="contact.html">CONTACT</a></li>
</ul>
</section>
<div style="margin-left:15%; margin-top:-10% padding:1px 16px;">
<h2>Products</h2>
<h3>Here is where the product name will be</h3>
<p>Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information.Information</p>
</div>
</section>
I swapped out the
section class="sidenav"
withaside class="sidenav"
. Also, you should define a width on your parent and usedisplay: flex;
. Then you can split up the child elements within by giving those awidth
also.