Reputation: 224
As you can see, the background color of <aside>
has not taken the full height of the page (empty white space above the nav bar), How do I fix this, so it takes the full height of the screen?
body {
margin: auto;
}
.container {
background-color: black;
color: white;
width: 7rem;
height: 100vh;
display: flex;
flex-direction: column;
text-align: center;
}
ul {
list-style-type: none;
padding: 1rem 0;
}
li {
padding-bottom: 2rem;
}
.header {
display: flex;
justify-content: center;
}
<header>
<div class="header">
<h1>Welcome</h1>
</div>
</header>
<aside>
<section>
<div class="container">
<nav>
<ul class="center">
<a>
<li>Home</li>
</a>
<a>
<li>Projects</li>
</a>
<a>
<li>Contact</li>
</a>
</ul>
</nav>
</div>
</section>
</aside>
Upvotes: 1
Views: 1795
Reputation: 4101
You can simply set the position
of the container to fixed
and thereafter make its height
to 100%
and set top
to 0
body {
margin: 0;
min-height: 100vh;
}
.container {
position: fixed;
top: 0;
height: 100vh;
background-color: black;
color: white;
width: 7rem;
display: flex;
flex-direction: column;
text-align: center;
}
ul {
list-style-type: none;
padding: 1rem 0;
}
li {
padding-bottom: 2rem;
}
.header {
display: flex;
justify-content: center;
}
<header>
<div class="header">
<h1>Welcome</h1>
</div>
</header>
<aside>
<section>
<div class="container">
<nav>
<ul class="center">
<a>
<li>Home</li>
</a>
<a>
<li>Projects</li>
</a>
<a>
<li>Contact</li>
</a>
</ul>
</nav>
</div>
</section>
</aside>
Upvotes: 1
Reputation: 28
Try setting the background-color to the body tag, or wrap the whole thing in a div, and set the background color on the div.
Upvotes: 0