What is the best way to ensure a vertical nav bar fills the entire height of a webpage?

Although this question has been asked before, the previous answer did not work for me. (100vh was suggested as a solution).

My goal is to extend the vertical navbar all the way to the bottom of the page. I have tried several different approaches but none of them seem to make it reach the bottom.

The code snippet labeled .rectangle is an attempt to draw a rectangular box that extends down the entire page. However, I faced the same issue with the rectangle as I did with the vertical navbar - it doesn't reach the bottom.

The .navContainer and .verticalNavBar are the initial codes I started with before experimenting with the rectangular box.

I am seeking assistance in identifying where the problem lies.

Here is the relevant code from the HTML and CSS files:

}
.navContainer {
    box-sizing: border-box;
    margin-left: 0%;
    margin-right: 15%;
    margin-bottom: 0%;
    background-color: grey;
}

.verticalNavBar {
    list-style-type: none;
    margin: 0%;
    padding: 0%;
    width: 15%;
    background-color: grey;
    position: absolute;
    min-height: 100%;
    overflow: auto;
}
.liVerNavBar a {
    display: block;
    color: #000;
    padding: 8px 16px;
    text-decoration: none;
}
<body>
    <div class="rectangle"></div>
    <nav class="navContainer">
        <ul class="verticalNavBar">
            <li class="liVerNavBar"><a href="Final_HomePage.html"><h2>Home</h2></a></li>
            <li class="liVerNavBar"><a class="active" href="Final_Resources.html"><h2>Resources</h2></a></li>
            <li class="liVerNavBar"><a href="Final_Medications.html"><h2>Medications</h2></a></li>
            <li class="liVerNavBar"><a href="Final_RequestMoreInfo.html"><h2>Request More Information</h2></a></li>
        </ul>
    </nav>

This is how the layout appears with the current code: Vertical navbar stops short of bottom

Even after changing .verticalNavBar so that it includes min-height: 100vh;

.verticleNavBar {
    list-style-type: none;
    margin: 0%;
    padding: 0%;
    width: 15%;
    background-color: grey;
    position: absolute;
    min-height: 100vh;
    overflow: auto;
}

the issue persists. When I updated .navContainer with min-height: 100vh;

.navContainer {
    box-sizing: border-box;
    margin-left: 0%;
    margin-right: 15%;
    margin-bottom: 0%;
    background-color: grey;
    min-height: 100vh;
}

the grey box around the navbar expands, almost taking up the full width of the screen.

Navbar taking up the width of the screen

Thank you for the responses provided thus far, but unfortunately, they have not resolved the navbar issue.

Answer №1

Typically, at the start of a stylesheet, you will find this type of configuration:

* {
  margin: 0;
  padding: 0;
}

This ensures that no default padding or margin is applied to any element by the browser.

If you are noticing an empty space at the bottom, it is likely due to this default behavior.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Collaborative Artistry: Using HTML5, JavaScript, and Node.js for Multiplayer

Creating a multiplayer drawing application for touch-enabled devices has been a challenge. I have utilized Node.js with Socket.io to draw points on a canvas, but there's an issue with the touchend event not resetting properly. To illustrate, take a l ...

Fancybox 2 - CSS styles vanish when using Ajax request

I have a fancybox2 with static dummy content that has styling applied. It works fine, but now I need to load dynamic content via ajax. However, when I make the ajax call, the required content loads but loses all css styling, most likely due to changes in t ...

Vertical text frozen at the top of a table

My goal is to design a table with frozen threads and vertically oriented labels in the header. I have made an attempt at implementing this below, but as a newcomer to CSS, I am facing several challenges. One issue I've encountered with my solution ...

Make sure to place the <i> tag within the <li> tag at the bottom to automatically resize the height

Currently, I am working on customizing my menu design with a mix of bootstrap and font awesome CSS styles. It would be easier to demonstrate the issue on a live page. My main objectives are two-fold: I want to position the chevron icon at the bottom with ...

What steps are involved in incorporating dynamic pagination in PHP using this particular snippet of code?

I am looking for a way to display a list of numbers from 1 to 1000 in a single line with the ability to scroll. However, I need to exclude both "Prev" and "1" from this list. How can I achieve this? Below is the code snippet that I currently have: echo ...

Center the SVG in the header using Bootstrap

I utilized a card template from Bootstrap for creating a warning card. The icon at the top of the card is an svg obtained from Bootstrap's icons library . On that page, you can find examples of how the icon should be aligned properly. However, in my i ...

Using jQuery to access the ID of a div and create a custom close button

I am trying to implement a close button for my popup DIVs. Each one has a unique ID and I want to hide them by setting the CSS 'display' property to 'none' when closed. However, the following example is not functioning as expected. I a ...

Include a character on the right side without shifting the text to the left

Below is the HTML code I am currently working with: <div class="last_img"> <p>Galutinė žetono išvaizda:</p> <span class="zetin11">A</span> <span class="zetin12">A</span> < ...

Learn the process of swapping an image with a button to trigger an onclick function using JavaScript

Currently, I am using an image button in JSP to trigger a JavaScript function upon click. The code snippet I have is as follows: <img src="<%= imagesDir%>/bt_pre.gif" onclick="return PreviousQ();" id="prevbtn" style="cursor: hand;"> The above ...

Choose a tag in order to connect to a different page when an event occurs in Rails

Working on my first complete stack rails application! I am trying to implement a select dropdown menu that will direct users to a specific show page within the app. Each option represents a different college with its own individual show page. I am struggl ...

What is the reason behind the failure of a distinct milestone (such as w-70) to show progress in Bootstrap, unlike w-25, w-50, w-75, and w-100, and what steps can be

As I navigate through Bootstrap using <div>, I aimed to reach a milestone of 70%. However, when I tried setting w-70, the progress bar only displayed around 5%. It seems that this issue persists with values like w-45, w-50, w-75, and w-100 only. Her ...

Using Bootstrap 4 to Filter Cards by Title and Tag

I'm attempting to develop searchable cards using HTML, JavaScript, and Bootstrap 4, but I'm facing issues with my code. My goal is to filter these three cards using a search bar, based on their title (h5.card-title) and tags (a.badge). Below is ...

I am having trouble retrieving dynamic values from a button using ajax. What could be causing this issue

I decided to create a unique dynamic button that utilizes ajax for calling when it's clicked. Each time the button is clicked, it pulls a fresh list of items from a specific website, resulting in its dynamic behavior. foreach($items as $item_link){ ...

Exploring Partial Views in Bootstrap Single Page View and AngularJS

Currently, I am utilizing Bootstrap's single page view design, specifically the one found at this link: http://www.bootply.com/85746. As my code in the view has grown to nearly 500 lines and is expected to expand further, I am seeking a method to crea ...

AngularJS seems to be ignoring CSS styles when displaying list items in the ng-repeat loop

After coming across a tutorial on creating round circles connected by a line in CSS, I decided to implement it myself. Interestingly, everything worked perfectly fine when I tested it with static HTML. However, when I tried to make it dynamic using Angular ...

Trouble with addClass failing to update CSS properties

I'm having trouble updating my add class. I'm attempting to create a sticky navigation bar, but the CSS on my site doesn't seem to be updating. None of the solutions I've found so far have been helpful. The website in question is antete ...

What is the method for creating a brand-new HTML object from scratch?

Similar Question: Preventing CSS styles from being applied to specific sections of code When HTML code is inserted into WordPress with multiple plugins, each may have its own style that automatically overrides global styles. To address this issue, one ...

Is there a sizing issue plaguing Chrome browsers?

Have you noticed any issues with Chrome version 16.0.912.63? I have applied the following CSS: #wholesale { margin: 0px 0px; width: 930px; text-align: center; display: table; border-top: 12px solid; line-height: 24px; } However, I am encountering a prob ...

PHP experiencing issues when trying to save data to MySQL database

I'm currently facing an issue with my HTML page that contains input fields. I'm using PHP to validate the data and insert it into my MySQL Database named 'fantasymock'. Despite successful validation, the data does not get written into t ...

Determine element height in Angular 5 by clicking on it

Currently, I am experimenting with determining the height of an element that I click on within a sidebar. The purpose is to display submenus accordingly. Below is the code snippet that I am working on: <li (click)="newsExpanded = !newsExpanded; getMarg ...