Expanding HTML zones to reach the bottom of the screen, while implementing top and side menus using the latest HTML5 and CSS techniques

Struggling to design a page layout with two navigation sections (top and left) similar to the example below:

The light gray area represents where the main content will be displayed on each page. On the left side is the secondary navigation menu that should extend all the way down to the bottom of the screen and align evenly with the main content area.

I'm having trouble adjusting the heights of both the left menu and the main content area so that they reach the bottom of the screen. I've been experimenting with width percentages, float, and position CSS properties to position them next to each other, but without success. It seems like the main issue is that I need to move the main content area up by 95 pixels using:

bottom: 95px;

Otherwise, the bottom right corner of the left navigation menu and the top left corner of the main content area overlap diagonally, leaving a large white gap below the title area before reaching the light gray main content area.

The only solution I've found to extend their heights to the bottom is by setting fixed pixel heights, but this doesn't work perfectly as I'm shifting the main content area up by 95px, resulting in a white gap below its bottom and it not aligning with the left navigation menu. Here's a snippet of my HTML structure:

<body>
  <header>
    <nav id="topMenu">
    </nav>
    <div id="titleAndUserInfo">
    </div>
  </header>

  <nav id="leftMenu">
  </nav>

  <section id="main">
  </section>
</body>

The navigation elements follow the pattern of ul li a

Update

I managed to get my CSS and HTML5 code working correctly for positioning, but the left navigation menu and the light gray main content area still don't extend to the bottom of the screen when there isn't enough content to do so automatically. How can I force this? Setting their heights to 100% or a specific pixel value doesn't seem to be effective. Here's my HTML, CSS, and the results viewed in Chrome:

<body>
  <header>
    <nav id="topMenu">
      <ul>
        <li><a href="/">xxx</a></li>
         <li><a href="/Home/About">xxxxx</a></li>
       </ul>
     </nav>
     <div id="titleUserLogin">
       <h1>Title</h1>
       Welcome <strong>test</strong>!
       <a href="/Account/LogOff">Log Off</a>
     </div>
   </header>
   <nav id="leftMenu">
     <ul>
       <li><a href="/">Home</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxx</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxxx</a></li>
       <li><a href="/">xxxx</a></li>
     </ul>
   </nav>
   <section id="main">
     <p>content</p>
   </section>
 </body>


/* General */
body {
  margin: 0;
  padding: 0;
  border: 0;
  height: 100%;
}

/* Header */
header {
  text-align: left;
  float: right;
  position: relative;
  width: 90.5%;
}

div#titleUserLogin {
  color: #fff;
  background-color: #303030;
  display: inline-block;
  width: 100%;
}

div#titleUserLogin h1 {
  display: inline;
}

div#titleUserLogin a {
  text-align: right;
  float: right;
}

/* Navigation menus */
nav#topMenu ul {
  padding: 0 0 2px;
  position: relative;
  display: inline;
}

nav#topMenu ul li {
  list-style: none;
  display: inline;
}

nav#topMenu ul li a {
  background-color: #303030;
  color: #fff;
  -webkit-border-radius: 4px 4px 0 0;
  -moz-border-radius: 4px 4px 0 0;
  padding: 10px 20px;
  line-height: 2.8;
  text-decoration: none;
}

nav#leftMenu {
  background-color: #303030;
  position: relative;
  float: left;
  width: 9%;
}

nav#leftMenu ul {
  position: relative;
}

nav#leftMenu ul li {
  list-style: none;
}

/* main content */
section#main {
  background-color: #d7d7d7;
  height: 100%;
  width: 90.5%;
  float: right;
  height: 100%;
}

Answer №1

Resolution:

To ensure the content of nav#leftMenu and section#main reaches the bottom of the screen, insert the following CSS rule and adjust the percentage heights accordingly:

html { 
  height: 100%;
}

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

The <a> tag does not lead to a different webpage and cannot be clicked on

I have developed a web component that includes a method to generate a copyright string: '<p>Copyright © 2020 John Doe<a href="https://www.example.com">. Terms of Use</a></p>' After creating the string, I conver ...

Where should I place my elements to ensure proper positioning in the Code Generator?

Hey everyone, I've been working on developing a code generator similar to Sketch2Code and I've hit a roadblock with my JSON structure. I'm trying to create an HTML page using the myData example provided with a predefined HTML structure. Thin ...

Step-by-step guide on achieving rounded borders with a gap:

Struggling to design blocks and elements with rounded corners that have a gap between the corner and the straight line. It's proving to be quite challenging :) Additionally, I need to create buttons that look like this, and If CSS alone doesn' ...

Tips for properly styling the input type range element

Is there a way to fix the issue with my input type="range" styling using linear-gradient when the variable is set to 75%? It seems to be behaving incorrectly. body{ background: green; } .wrapper { width: 20vmin; } input { widt ...

What happens when data is managed in getStaticProps and utilized in useEffect within a component?

On my page, I utilize the getStaticProps function to fetch a list of objects containing book titles, authors, and character lists. Each object is then displayed within a component that formats them into attractive pill-shaped elements. The component rende ...

Trouble with Bootstrap 5 Dropdown Functionality

Currently, I am using Bootstrap 5 in conjunction with Django to create a website and I'm encountering difficulties with getting a dropdown feature to work properly. Despite copying the code directly from w3schools, it fails to function when I load the ...

Interactive World Map with Fluid Motion Animation built using HTML, CSS, and JavaScript

I am in need of an uncomplicated way to visually represent events taking place around the globe. This involves creating a 2D image of a world map, along with a method to show visual alerts when events occur at specific geographical coordinates [lat, lng]. ...

css Repaint the CSS by filtering out list items with odd indexes

Having a list of over 20 items, I utilized the :nth-child(2n+1) selector to alternate the background color (even item in black, odd item in white). However, when using the jQuery Isotope plugin to filter out specific items by adding a .isotope-hidden class ...

Attempting to render an image onto a canvas and apply Caman.js for image editing purposes

Currently, I have a code snippet that allows me to draw an image onto a canvas. Here is the code: var imageLoader = document.getElementById('imageLoader'); imageLoader.addEventListener('change', handleImage, false); var ...

What is the best way to ensure that a specified number of list items (li) will align properly within the width of an unordered list (ul

I'm attempting to make all the li elements' width match that of my ul element. Here is the code I am using: http://jsfiddle.net/4XR5V/2/ I have looked at some similar questions on the website and tried adding: ul { width: 100%; display: tab ...

The functionality of getElementsByClassName and appendChild is not producing the desired outcome

First of all, the solutions must strictly adhere to VanillaJS. I am presenting a straightforward HTML code snippet below: <div class="x">X</div> <div class="x">Y</div> <div class="x">Z</div> Accompanied by a block of ...

The scrolling feature induces a contraction to the left side

Recently, I implemented the code below to fix my menu when scrolling the page: var num = 5; $(window).bind('scroll', function () { if ($(window).scrollTop() > num) { $('.scroll').css({'position':'fixed&apo ...

Is it possible to directly add a child in HTML from nodejs?

I'm in the process of developing a chat application that requires users to select a room from a list of available rooms stored in <datalist> options, which are fetched from a SQL table on the server. Within my login.html file, users are prompte ...

Array of materials for ThreeJS GLTFLoader

Attempting to load a model using GLTFLoader and apply different colors for each face of the object (cube) using a material array is not functioning as expected. var materials = [ new THREE.MeshPhongMaterial( {color: 0x552811,specular: 0x222222,shininess: ...

The Challenge with jQuery Nano Scroll

I recently added the jQuery Nano Scroll plugin to my HTML page. However, I am facing an issue where the scrollpane is not visible. When I inspect the div using Chrome, the scrollpane appears. Any suggestions on how to resolve this? Here's a snippet ...

I am struggling to save the value from my input field into the app.component.ts file

Having some trouble storing an input from my form into a property. After submitting, the console.log is showing undefined in the console. I've experimented with different variations, but none seem to be working as intended. <form> <input #i ...

Having trouble setting a value as a variable? It seems like the selection process is not functioning properly

My Hangman game has different topics such as cities and animals. When a user selects a topic, the outcome should be a random item from that specific topic. For example: London for cities or Zebra for animals. Currently, I am only generating a random lett ...

Generate a link to download a music or video file

I have an HTML file containing both video and audio files. I want to link these files, such as MP3 or MP4, using the <a href> tag to allow users to download them. The video and audio files are stored in the same folder as my HTML file. I have attemp ...

Get the application/pdf document that was just sent to you from the software backend

I am facing an issue with downloading a PDF file sent from the backend. Upon receiving a blob response, I notice that when I download and view the file, the sheets are empty, matching the expected number of sheets. Could this be a coding problem? Current ...

clicking on a DIV element

I am trying to trigger a JavaScript function by clicking on a DIV element, but for some reason it is not working as expected. I have gone through various examples provided by the helpful people here, but still can't figure out what I'm doing wron ...