Moving the sidebar from the app component to a separate component in Angular results in a situation where the sidebar does not maintain full height when the page is scrolled down

Within my Angular application, I have implemented a sidebar as a separate component. Previously, the content of the sidebar was housed within the main app component's HTML page, and it functioned properly by taking up the full height of the page when scrolled. However, after transitioning this content to a separate component and including it within the app component, the sidebar no longer expands to the full height of the page when scrolling down, as illustrated in the screenshot below:

https://i.stack.imgur.com/Wej29.png

The code snippet from the sidebar.html file is as follows:

<nav *ngIf="isLoggedIn$ | async" id="sidebar" [ngClass]="{active: (isShown$ | async)}">
      <div class="sidebar-header">
         <h2>Test Portal</h2>
      </div>

      <ul class="items">
         <li [routerLink]="['/car-list']" routerLinkActive="active" title="Cars">
            <a>
               <fa-icon [icon]="faLayerGroup"></fa-icon><span id="spnCars">Cars</span> 
            </a>
         </li>
         <li [routerLink]="['/bike-list']" routerLinkActive="active" title="Bikes">
            <a>
               <fa-icon [icon]="faUsers"></fa-icon><span id="spnBikes">Bikes</span>
            </a>
         </li>
      </ul>
   </nav>
   

Furthermore, here is a portion of the styling defined in the sidebar.scss file:

#sidebar {
      font-family: 'Poppins', sans-serif;
      min-width: 200px;
      max-width: 200px;
      min-height: 100vh;
      background: #7386D5;
      color: #fff;
      transition: all 0.3s;
   }
   
   (...additional CSS styling for the sidebar...)
   
   

In the app.component.html file, the "app-sidebar" section houses the sidebar content within the overall structure of the page:

<div class="wrapper">
      <app-sidebar></app-sidebar>
      
      <!-- Page Content -->
      <div id="page-content">
      
          <div id="content">
              <router-outlet></router-outlet>
          </div>
      </div>
   

Additionally, the corresponding styling in the app.component.scss file maintains the layout and dimensions of the page:

.wrapper {
      display: flex;
      width: 100%;
      align-items: stretch;
   }
   
   (...additional CSS styling for the wrapper and page content elements...)
   
   

If anyone can shed light on why the sidebar is not occupying the full height of the page upon scrolling, your assistance would be greatly appreciated.

Answer №1

When you set the min-height of the #sidebar to 100vh, it means the sidebar will only be as tall as the current view's height and won't extend beyond that (the current view refers to your browser window).

To solve this issue, all you need to do is set the height of the #sidebar to 100% so that it matches the height of its parent element (which, in this case, is the

...
).

I hope this explanation helps clarify things for you!

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

Is there a way to set up an automatic pop-up for this?

Experience this code function AutoPopup() { setTimeout(function () { document.getElementById('ac-wrapper').style.display = "block"; }, 5000); } #ac-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; back ...

The functionality of classes containing <ul> elements is ineffective

Having recently embarked on the journey of learning html/css, I've encountered some confusion along the way. Allow me to showcase my basic web-page layout: <html> <head> <meta charset="utf-8"> <link rel = "stylesheet" type="text ...

Angular7 & Bootstrap4: Creating a collapsible navigation bar

Currently, I am working on creating a navbar with a collapsible animation that functions properly on mobile screen sizes. I have been following a tutorial which has guided me in the right direction: . Although I have successfully implemented the functiona ...

Pass the ID and content of a textarea element by utilizing the AJAX post method and incorporating SweetAlert version 2 for a seamless and

function solveTheIssue(id) { promptUser({ title: "Share your complaint", input: "textarea", showCancelButton: true, confirmButtonColor: "#DD8B11", confirmButtonText: "Yes, submit it!", ...

Ways to update the select field without having to reload the entire page

I am working on a unique feature that involves two levels of drop down menus. When a user makes a selection in the first level, a corresponding set of options will appear in the second level. For example, I have 6 options in the first level, each with its ...

Guide to incorporating JSON data into HTML through JavaScript

As I attempt to load data from a JSON file to .js and then to an HTML file, I am facing a challenge. While I can successfully load the JSON values into .js, I am unable to transfer the same values to HTML. Below is the code snippet - could anyone provide a ...

Using Angular 2 to inject JSON data through HTTP requests

http://localhost:3000/userinfo [ { "username": "simon", "password": "password1" }, { "username": "bala", "password": "password2" }, { "username": "prabha", "password": "password3" } ] myservice.service.ts import { Inje ...

What is the best way to incorporate sound into a button using HTML or CSS for maximum impact?

Can anyone help me with a school project? I need to make a button play a sound when clicked. I've tried using both the <button> and <audio> tags, but they don't seem to be working for me. Perhaps CSS could be a solution. So far, the o ...

Variations in CSS display across various browsers

I'm currently facing an issue while learning web development. The expected result only appears when I preview my website on an old version of Internet Explorer, but it doesn't show up correctly when opened on Firefox or Chrome. The code I have i ...

Having trouble with the HTML5 canvas for loop not rendering the initial object in the array?

Essentially, I'm attempting to iterate through each letter in a text string (specifically the text "marius"). However, there's an issue where the first letter is not being displayed. When the text is "marius", only "arius" is drawn. I've exh ...

Tips for integrating SASS from the Bulma package into an Angular application

I'm currently working on implementing Bulma into my project. The documentation suggests using NPM to obtain it. yarn add bulma Further in the documentation, there is an example provided with code snippets like the ones below. <link rel="styles ...

Mysterious obsidian container lurking in the background of the video on Chrome version 67.0.3396

Displayed on the page is an HTML Video tag, which streams a video from the speaker (WebRTC). <div id="remoteVideoContainer"> <video id="remotevideo" autoplay="autoplay" controls="" loop="loop" preload="true" height="500" width="100%"> ...

The most sophisticated method for creating a 2x2 grid of divs

I have developed a quiz application similar to Buzzfeed with four answer options for each question. The layout on mobile devices is satisfactory, displayed in a 2x2 grid. However, when viewing the app on desktop screens, the answers appear horizontally in ...

The Laravel href link will fail to work when the URL does not include the string 'http'

I am encountering an issue with a particular hyperlink tag <a href="{{ $organization->website }}">Link</a> When the URL in $organization->website does not start with http:// or https://, the link fails to direct me properly. Instead, it r ...

Which Angular2 npm packages should I be installing?

When I'm trying to create an empty app without using angular-cli, it's really difficult for me to figure out which packages or libraries to include. Searching for angular2 on npmjs yields unwanted results, forcing me to click through multiple li ...

Tips on displaying the entire text when hovering over it

I'm facing an issue with a select element that retrieves options from an API. The problem is that some options are too large for the text box and get cut off, making them hard to read for users. <div class="form-group my-4"> <lab ...

Tips for styling Ajax.ActionLink elements with CSS

Hi there, I'm trying to style a navigation bar using CSS. I'm pulling the navigation bar values from a database using Ajax.ActionLink. I attempted to use JavaScript but encountered an error stating "jQuery is not defined", Here's the cod ...

Using Modernizr to determine the presence of nth-child in a test

I'm attempting to utilize modernizr in order to check for browser support of the :nth-child selector, but I am unsure of how to proceed. I came across this particular example on http://jsfiddle.net/laustdeleuran/3rEVe/ which tests for :last-child. How ...

Can a div section be defined and then filled with data in the same document?

Is it possible to initially declare a div section and later populate it with content in the same document? The following dummy code snippet illustrates the query... <div name="xyz" style="..."> <!-- Empty --> </div> < ... INTO "x ...

Navigating the screen reader with the cursor位

Site Design Challenge I recently discovered that the master/detail design of my website is not very accessible. The main view features a column chart where each column represents a different month. Clicking on one of these columns reveals details in a nes ...