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

Issues with Angular 2 Cli setup

Exploring the world of Angular 2, I decided to dive into the installation process of angular2 cli. However, upon executing 'ng new newapp' after installation, an unexpected error appeared where 'mg' was referenced rather than 'ng&a ...

Position divs to align text beside icons

I am currently working on a Bootstrap popover to display various pieces of information, each containing an icon and some text. Additionally, I am incorporating twig into this project. Here is the HTML structure: <span class="fa fa-user instructor-con ...

What steps can I take to enhance the responsiveness and overall performance of this code using bootstrap?

Struggling with making your website responsive? No worries, we've all been there. Whether you're a pro at coding in react.js and vue.js or a complete beginner, we all need to start somewhere. Any suggestions or tips on how to improve responsivene ...

Sending the parameter with the URL and receiving the response in return

Can the result be retrieved by calling a URL and sending specific parameters with it? For instance, if I pass two numbers along with the URL, can I receive the sum in return? The addition operation is carried out on the page being called upon. ...

Tips for displaying animations only the first time using HTML and CSS:

Upon the initial visit to my website, a captivating animation introduces itself with the words "Hello. I'm Bob" as it gracefully fades into view. Navigating through the menu bar allows users to explore different sections of the site. However, there ...

Issue with Angular 6: Unable to locate identifier 'require' while trying to request xml2json node

Recently delving into Angular, I've been exploring the installed node modules and how to use them in a data.service.ts file. Everything below executes flawlessly! var isWindows = require('is-windows'); console.log("Is this windows? " + isWi ...

Leverage the power of Bootstrap by incorporating not one, but two carousels on a single page - one featuring a single item per

I have a unique challenge with using multiple Bootstrap Carousels on my WordPress website One of the carousels features one item per slide, while the other carousel has three items per slide, moving one item at a time in a cyclical pattern like this: [1, ...

Bug in timezone calculation on Internet Explorer 11

I've spent hours researching the issue but haven't been able to find any effective workarounds or solutions. In our Angular 7+ application, we are using a timezone interceptor that is defined as follows: import { HttpInterceptor, HttpRequest, H ...

What steps should I follow to customize the Bootstrap link template according to my requirements?

In the bootstrap documentation, the links are shown in blue by default. I want them to be white instead. How can I make all the links white if the documentation is ignoring my CSS files? ...

Issue with displaying labels in ChartJS plugin on Ionic 3 platform

Currently, I am using Ionic 3 and have implemented a bar chart in my project. However, I am facing an issue where the data labels are not being displayed next to the bars on the chart. This is similar to the problem discussed in this question how to displa ...

Wrap link column data in a bootstrap table for a seamless display

Is there a way to make a link in a table cell wrap and respect the column width I provide? When data in a table cell is a link, it doesn't seem to let me specify the column width. How can this be achieved? <link href="https://cdn.jsdelivr.net/np ...

CSS experts caution that the addition of margin and padding can cause the screen to jump

When I apply margin and padding to this class, it starts glitching like in the second GIF. However, if I remove margin and padding everything works fine, but I do need them for styling purposes. What could be causing this issue and how can I resolve it? ...

Establish a connection between an Angular client and a Spring backend using JWT for authentication

I successfully integrated JWT into my Spring backend by following the steps outlined in this informative guide: https://auth0.com/blog/securing-spring-boot-with-jwts/ Interestingly, when I perform a PUT request using Postman, everything seems to be workin ...

Variation in `th` & `td` Width in Table

Is it possible to have different widths for th and td, such as 50px for th and 500px for td? To address this issue, I am utilizing datatable. To enable others to help me, here is a simple code snippet: .abc { width: 500px; } .def { width: 50px; } ...

Angular is having trouble with the dropdown feature when using Semantic UI

I'm having trouble with the dropdown not displaying any items when I click on it. Here is the source code for reference: <div class = "ui centered grid"> <div class = "ten wide column"> <form class = "ui form"> <h4 cl ...

Incorporating Precision to Decimal Numbers in TypeScript Angular

Having some trouble with this issue and I've tried various solutions without success. This problem is occurring within an Angular project. The requirement is to always display a percentage number with two decimal places, even if the user inputs a who ...

What is the process to create text in bold format in an HTML document?

I'm having difficulty making certain text bold with HTML. Unfortunately, I can't seem to figure out the correct method. Here is my attempted code snippet: Some <bold>text</bold> that I'm trying to highlight. Could someone prov ...

Element on navigation bar extending full width of the page

As a fairly new designer, I am facing an issue with my navbar button. Currently, it is only 100 pixels wide and fixed in place, allowing the rest of the page to scroll past it. However, although it is confined to 100PX in width, it still spans across the e ...

What is the process for connecting an HTML page to a CSS file located in a parent directory?

Here's the problem I'm facing: I recently encountered some organizational issues with my website, so I decided to reorganize my files for better classification. The current folder structure looks like this: www resources images ... css de ...

Error: The AppModule encountered a NullInjectorError with resolve in a R3InjectorError

I encountered a strange error in my Angular project that seems to be related to the App Module. The error message does not provide a specific location in the code where it occurred. The exact error is as follows: ERROR Error: Uncaught (in promise): NullInj ...