Angular4 paired with Bootstrap 4 creates a sleek and stylish footer positioned at the bottom of the

I have already done extensive research on Google and this board, trying numerous solutions without success. My goal is to have a footer positioned at the bottom of every site, even if the site does not reach the bottom of the viewport.

Using Angular4 and Bootstrap4, below is my current code snippet (split into two templates due to limitations):

<mat-toolbar color="primary" class="mat-elevation-z2" *ngIf="auth.isLoggedIn()">
<button mat-button class="pull-left" [disabled]="!auth.isLoggedIn()" (click)="sidenav.toggle()">
    <i class="fa fa-navicon" aria-hidden="true"></i> PowerPals
</button>

<div *ngIf="auth.isLoggedIn()">
    <button mat-button class="pull-left" (click)="showProfile()">
        <i class="fa fa-user" aria-hidden="true"></i><span class="d-none d-sm-inline"> {{auth.username$ | async}}</span>
    </button>

    <button id="logoutButton" mat-button class="pull-right" (click)="logout()">
        <i class="fa fa-power-off" aria-hidden="true"></i><span class="d-none d-sm-inline"> LOGOUT</span>
    </button>
</div>

<mat-sidenav-container (window:resize)="onResize($event)" [style]="mainStyle.getValue()">
<mat-sidenav *ngIf="auth.isLoggedIn()" [mode]="sidenavMode" [opened]="true" #sidenav class="sidenav-shadow">
    <app-nav-pane *ngFor="let nav of (app.navmods$ | async)" [content]="nav"></app-nav-pane>
</mat-sidenav>
<div class="container-fluid">
    <div class="row" style="flex: 1 0 auto;">
        <div class="col-12">
            <router-outlet></router-outlet>
        </div>
    </div>
</div>
<footer>
    <div class="footer-copyright">
        Footer
    </div>
</footer>

Currently facing an issue where the footer is not positioned at the bottom of each page or viewport as intended. The layout looks like this:

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

I am seeking a solution to ensure that the footer consistently stays at the bottom. None of the CSS solutions I have come across have provided satisfactory results.

Any assistance or suggestions would be greatly appreciated :-)

Answer №1

To implement a solution, you can utilize the card-footer and fixed-bottom CSS classes (refer to: Bootstrap version 4 fixed-bottom). Here is an example:

<footer class="card-footer fixed-bottom"><div>Content goes here</div></footer>

Ensure that the footer is placed after the closing tag of </mat-sidenav-container>.

Note: By following this approach, the footer will remain visible even when the sidenav is hidden as it is positioned right after the sidenav-container closes.

Answer №2

Adding on to the response provided by Daniel C.

It is also possible to utilize the footer component without including a card.

For instance:

<footer class="fixed-bottom"><div>This is my footer</div></footer>

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

What could be the reason for the top alignment of only a portion of the cell

Here is the code snippet I am working with: <html> <head> <style> table.t_group { border: 2px solid black; margin: 0 auto 0 auto; } table.t_group > tbo ...

Dynamically Modify Custom Style Class Properties in JavaFX Using CSS

Embarking on my CSS journey, I have limited experience since I mainly worked with JavaFX applications and not web languages. In one of my JavaFX applications, I utilized a css style sheet featuring a Windows 10 UWP theme. The default style classes adhere t ...

Creating universal CSS for all platforms

Seeking assistance in making this Chrome CSS code compatible across different platforms. It currently does not function properly in Firefox and is completely non-functional in IE8. Your help is greatly appreciated, thank you for taking the time to read. . ...

Struggling to perfectly center the NavBar within the wrap container

After working on my navbar and utilizing this site for guidance, I was able to center it using text align. However, there is an odd indent in the navbar that I can't seem to figure out. This indentation throws off the alignment when centered, giving i ...

Zooming on a webpage is causing problems

One issue I'm facing is with the elements on my page acting strange when I zoom in and out. Everything seems to be working fine except for a container div that should overlay a color over the image background. When I zoom in or switch to mobile view, ...

What is the best way to incorporate custom styles in CKEditor with the help of the Custom drop

I recently implemented a plugin that provides me with the code needed to create a dropdown menu on my CKeditor toolbar. This dropdown menu contains various styles that can be applied by clicking on them. Here is the code snippet: CKEDITOR.plugins.add( &ap ...

What is the best way to split a word within a list item in Bootstrap 4?

I am currently facing an issue with a list created using Bootstrap 4, where some items contain long text that is causing problems on small screen devices. I have attempted to use white-space:nowrap and the text-nowrap class, but neither solution has fixed ...

Responsive Bootstrap 5 table - occupies full width on mobile devices, adjusts automatically on desktop screens

Is there a way to create a table that is full width on mobile using pure bootstrap classes, but only auto width on desktop? I attempted to achieve this with the following code: <table class="table table-bordered w-md-auto w-100 text-start mb-2&quo ...

Losing scope of "this" when accessing an Angular2 app through the window

My Angular2 app has exposed certain methods to code running outside of ng2. However, the issue arises when calling these methods outside of ng2 as the context of this is different compared to when called inside. Take a look at this link to see what exactl ...

Having trouble with the jQuery toggle functionality not working as expected

I'm implementing a function where a div should increase in height and opacity when clicked, and then revert back to its original state when clicked again. I used the toggle function for this purpose, but the issue is that the button disappears when th ...

Issue encountered when attempting to access disk JSON data: 404 error code detected

I am attempting to retrieve JSON data from the disk using a service: import { Product } from './../models/Product'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { HttpClient } from &apo ...

Unable to change font using jquery - issue persisting

I am struggling to modify the font of a specific text in the following code, as it keeps displaying a page error. function adjust_font_style(div_id) { $("#testsave").html(<strong onclick=\"javascript:save_font_changes("+div_id+",font,'Ar ...

Customizing the text color of words that originated from a dropdown selection within an Angular textarea editor

My Process: Within my interface, I utilize both a dropdown menu and a textarea field. I input text into the textarea and select certain words from the dropdown menu to add to the textarea. I have successfully completed this task. The Issue at Hand: Now, ...

Can @keyframes be iterated through CSS (particularly Stylus)?

Here is some Stylus code I'm working with: for i in (1..3) .l:nth-child({i}) opacity (i / 5) When executed, the output looks like this: .l:nth-child(1) { opacity: 0.2; } .l:nth-child(2) { opacity: 0.4; } .l:nth-child(3) { opacity: 0.6; } ...

Repeatedly invoke http.post function and finally return the observable

In order to attach the list of documents, each document can contain a maximum of 20 MB data and the user has the ability to attach an unlimited number of files. Consequently, I am initiating one file upload per REST call. Upon successfully saving all the ...

jQuery slideDown() is taking precedence over the final element

I'm having trouble sliding a submenu dropdown on my mobile site. The last element is not moving out of the way as expected, and it's expanding over the current selector. Here is the code snippet: <li class="dropdown"> <a href="#">S ...

What is the best way to create a clickable image?

Review the following HTML code: <div id="panelpic1"> <a href="https://www.google.com/"style="display:block"target="_blank"> </a> </div> CSS details: #panelpic1{ content: ...

<Angular Command Line Interface> Implement a script within an HTML file that takes a parameter from a separate .ts file

Hey there! Sorry if it's a bit unclear, but here's the issue: I have a file called "heroes.ts" with numerous objects for a "Hero" class (exported from another file), and here is a snippet of it --> import { Hero, Villain } from '../her ...

Is there a way to incorporate a delete button for each li element that is included in my list?

I have successfully implemented a to-do list where clicking on an item strikes a line through it and there is a delete button that works. However, I am looking for assistance on how to create a delete button for each newly added li item. var button = do ...

Transforming JSON data into an HTML template

Incorporating Angular 6 in my project, I have come up with the following templates: Header, Left panel, Body part, Footer Header, Left panel, Body part, Right panel, Footer Header, Body part, Footer Considering the numerous templates, I am aiming to tran ...