The mdb navigation bar seems to constantly change its height

Having an issue with the height of my mdb navbar in my Angular app. It randomly flips to a larger size when reloading the page, but returns to normal when I open the developer console in Chrome.

Two screenshots show the correct display and the incorrect increased height:https://i.sstatic.net/Lvt8k.png https://i.sstatic.net/yItmZ.png

The navbar is in a separate Angular component added to the app.component.html like this:

<app-header></app-header>
<div class="d-flex p-2 justify-content-center">
  <router-outlet></router-outlet>
</div>

The header structure resembles the example provided by mdb

<mdb-navbar SideClass="navbar navbar-expand-lg navbar-dark indigo" [containerInside]="false">
  <mdb-navbar-brand>
    <a class="navbar-brand" [routerLink]="'/dashboard'">Admin Console</a>
  </mdb-navbar-brand>
  <links>
    <ul class="navbar-nav mr-auto">
      <li class="nav-item" routerLinkActive="active">
        <a class="nav-link waves-light" mdbWavesEffect [routerLink]="'/dashboard'">Dashboard</a>
      </li>
      <li class="nav-item" routerLinkActive="active">
        <a class="nav-link waves-light" mdbWavesEffect [routerLink]="'/todo'">Users</a>
      </li>
      <li class="nav-item" routerLinkActive="active">
        <a class="nav-link waves-light" mdbWavesEffect [routerLink]="'/todo'"">>A</a>
      </li>
      <li class="nav-item"> routerLinkActive="active">
        <a class="nav-link waves-light" mdbWavesEffect [routerLink]="/todo">B</a>
      </li>
    </ul>
    <span class="fill-remaining-space"></span>
    <ul class="navbar-nav ml-auto">
      <li *ngIf=!authService.isLoggedIn class="nav-item">
        <a class="nav-link waves-light" mdbWavesEffect [routerLink]="'/sign-in'">Login</a>
      </li>
      <li *ngIf=authService.isLoggedIn class="nav-item">
        &$lt;a class="nav-link waves-light" mdbWavesEffect (click)="this.authService.signOut()">Logout</a>
      </li>
    </ul>
  </links>

I attempted adding sticky-top as Sideclass to improve behavior when fixed content resides inside the router-outlet. However, the issue resurfaces when dynamic content like a table is loaded into the router-outlet as shown here:

https://i.sstatic.net/SVPHp.png

Any suggestions on how to prevent the navbar from resizing? Thank you!

Answer №1

It appears there is a glitch in the component, but I have discovered a workaround. It seems that the div injected into the nav element has a style attribute used to control the height when the drop-down is active. The intended behavior is for the height to only increase when the drop-down is active, but in my case, it was increasing sporadically. To address this, I utilized the following CSS code to limit the max-height of the navbar when it is not in drop-down mode:

:host ::ng-deep mdb-navbar nav div :not(.show) {
    max-height: 40px !important;
}

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

When I apply filtering and grouping to the table, the rows in the mat table disappear

When using mat-table, grouping works fine without filtering. However, once the table is filtered or if the search bar is focused, ungrouping causes the rows in the table to disappear. I am looking for a solution that allows me to group and ungroup the tabl ...

The website is displaying a strange mix of text and HTML when viewed on a PC

While browsing the internet for C programs, I stumbled upon this particular program that caught my eye: <span style='color:#004a43'>#</span><span style='color:#004a43'>include</span><span style='color:#8 ...

Solving CORS policy error in a MEAN stack application deployed on Heroku

I've been grappling with a CORS policy error in my MEAN stack app for quite some time now. The specific error message I keep encountering is: "Access to XMLHTTPRequest at <my heroku app url.com/login> from origin has been blocked by CORS ...

Discovering the bottom scroll position in an Angular application

I am working on implementing two buttons on an Angular web page that allow the user to quickly scroll to the top and bottom of the page. However, I want to address a scenario where if the user is already at the very top of the page, the "move up" button sh ...

Position an HTML canvas at the very top of the webpage

Can someone help me figure out how to align a canvas element to the very top (0, 0) of a webpage? I attempted using margin: 0; padding: 0px;, but it didn't work. There always seems to be some white space at the top that I can't eliminate. ...

Exporting a class from an index.ts file may result in a problem where the injected constructor is

Utilizing an index.ts file to manage exports, following the guidelines outlined in the Angular 2 style guide (https://github.com/mgechev/angular2-style-guide/blob/master/old/README.md#directory-structure), has been successful throughout my application deve ...

What is the necessity of Node Js for Angular and how does Angular Cli play a pivotal role?

As a newcomer to the world of Angular technology, I stumbled upon this intriguing query. What is the role of Node.js in Angular? After all, isn't Node.js primarily a backend technology? ...

Is AsciiEffect.js compatible with CSS3DRenderer.js in combination with three.js/WebGL?

Having trouble using the AsciiEffect.js and CSS3DRenderer.js together, wondering if it's possible without tweaking... here's the concept var W = window.innerWidth, H = window.innerHeight; renderer = new THREE.CSS3DRenderer(); effect = new THREE. ...

Is it possible for Angular2 to map a lone JSON object?

Dealing with a JSON response that is a single object, rather than an array, can be tricky. Recently in my project, I encountered a situation where I needed to map and use such a response from an API to fill out a template. It seemed like a simple task at f ...

The container's :before pseudo-element features a sleek white border

I have been experimenting with using the :before and :after pseudo-elements to generate diagonal lines within a container. However, I am encountering an issue where these pseudo-elements appear to have a white bottom border, and I am unable to determine t ...

"Utilize Typescript to dynamically check data types during runtime and receive alerts for any potential

INTRODUCTION I am currently working with Angular 6. In Angular, typescript is utilized to allow you to specify the data type of your function's arguments: public fun1(aaa: number) { console.log(aaa); } If I attempt to call fun1 with a parameter ...

Is there a way I can ensure that two elements have identical heights?

Is there a way to ensure that two different elements in HTML are always the same height using CSS? I attempted to achieve this by setting each element to 50vh in the CSS, but it didn't work. codepen: https://codepen.io/ichfickedeinemutterdudummerwich ...

ERROR : The value was modified after it had already been checked for changes

Encountering an issue with [height] on the main component and seeking a solution Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '753'. Current value: '731'. I have th ...

Is it possible to determine if an HTML form has been modified?

Is there a way in typescript to determine if a form has been changed and return true or false accordingly? For example, if I have a first name field with the current value of "John" and then change it to "Johny", it should return true. But if I revert it b ...

What is the reason behind requiring {[param: string]: string | string[]} for the HTTP GET attribute [params]?

Problem Statement An error occurs during type inference in this.http.get() Error TS2322: Type 'Observable<ArrayBuffer>' is not assignable to type 'Observable<IInfo[]>'. Type 'ArrayBuffer' is missing the followin ...

Avoid filling the container with an excessive amount of grids while maintaining the correct aspect ratio

I encountered a situation where I needed to dynamically create a grid with square grids of dimensions MxN. Below is the code snippet for achieving this: rerender = (event) => { const height = document.getElementById("y-input").value; const width ...

What factors dictate the color of rows in jquery datatable designs?

Within the jQuery datatable styles, such as "smoothness," the rows are displayed in different colors. What factors determine which colors are shown on each row? And is there a way to customize this color scheme? Refer to the example below from their sampl ...

What causes compilation errors while attempting to integrate Angular elements into a Material Dialog component?

I attempted to set up a basic Angular application with a Material Dialog, but encountered difficulties when trying to include any Angular-specific elements in the HTML of the dialog (such as using <mat-dialog-content> or [(ngInput)]), resulting in co ...

Troubleshooting problem with JQuery window printing capability

After creating a paper with dimensions of 21.0 cm width and 29.7cm height, I encountered an issue where the printer output three papers instead of just two. I am not sure where I went wrong in my setup. You can find the source code here. window.print(); ...

Angular 4 not throwing errors when using Array.Filter and find

Having trouble filtering a list using Array.find and filter functions. Here is the function in question: setSupplierDetails(supplierId) { const supplier = this.suppliers.filter(tempSupplier => tempSupplier.id === supplierId)[0]; this.supplierName = ...