Tips for ensuring a footer remains fixed at the bottom of a webpage, despite any increase in content

As I work on my single-page application, I'm playing around with a shared footer layout. My goal is to keep this footer at the bottom of the page at all times. However, I also want to explore the possibility of hiding it in certain routes, even though it's declared in the app.component.html file.

I've experimented with different footer positions using SCSS.

app.component.html

<div class="grid-container">
<main [@fadeAnimation]="o.isActivated ? o.activatedRoute : ''">
<router-outlet #o="outlet"></router-outlet>
</main>
<rb-footer class="footer"></rb-footer>
</div>
<rb-modal></rb-modal>

app.component.scss

:host {
    .grid-container {
      display: grid;
      grid-template-rows: auto 1fr auto;
      grid-template-columns: auto;
      height: 100vh;
    }

.footer {
  position: initia
  width:100%;
  height:40px;

  }

  }

Answer №1

GET READY FOR THE FLEXBOX REVOLUTION !!

header, footer, content { display: block; }

container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  max-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

header {
  flex: 0 0 50px;
  height: 50px;
  background: coral;
}

footer {
  flex: 0 0 50px;
  background: coral;
}

content {
  flex: 1 1 auto;
  overflow: hidden;
  overflow: auto;
  background: teal;
}
<container>
  <header></header>

  <content>
    <div style="width: 200vw; height: 200vh;"></div>
  </content>

  <footer></footer>
</container>

Embrace the power of flex layouts where your content flows effortlessly! Experience the beauty of Angular's customized implementation and witness how user-friendly it can be!

Answer №2

footer styling: {position fixed; bottom of page: 0;}

I trust this information is beneficial ;)

Answer №3

To ensure consistency across all pages, it is recommended to create a footer.html file and include it in app.html. If you only want it on certain pages, you can simply add the header at the end of each respective page. Adding the footer can be done like this:

In the app file:

<div data-ng-include=" 'tpl/blocks/footer.html' " >

Alternatively, in a separate file:

<div  ng-include="'tpl/blocks/footer.html'">
    {% include 'blocks/footer.html' %}
</div>

Answer №4

FOR SINGLE PAGE APPLICATIONS

.footer{
position:fixed;
bottom:0px;
background-color:red;
width:100%;
height:30px;
}
.footer p{
text-align:center;
color:white;
margin-bottom:0px;
}

.header{
background-color:blue;
height:30px;
}

.header p{
text-align:center;
color:white;
margin-bottom:0px;
}
<div class="header">
<p>Header-logo<p>
</div>
<div class="footer">
<p>Footer-logo<p>
</div>

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

Updating to Angular 6 from backbone

At the moment, my current project is utilizing backbone js as a hybrid application. I am considering migrating this backbone Js application to angular 6, but first, I would like to understand why angular is superior to Backbone Js in the context of build ...

Dynamically setting CSS values with jQuery to center an image within a div

I'm trying to center an image in a div according to the width of the image after I scale it to have a height of 250px. For example, if I had an image with dimensions 625x450 and, in my CSS file, set the height of the image to be 250px, then the width ...

CSS :before pseudo element is capable of displaying only one element, not both, on separate elements

I am currently working on integrating FA icons into WordPress sidebar widgets, and I have encountered some challenges with displaying the icons as intended. When targeting two separate items, only one of them displays the icon in the given code snippet. A ...

Issues encountered with sending post requests to a yii2 application when using Angular4

After implementing the following code: this.http.post('http://l.example/angular/create/', {name: 'test'}).subscribe( (response) => console.log(response), (error) => console.log(error) ); I encountered an error on ...

Looking for a solution to organize the dynamically generated list items in an HTML page

I am currently working on a movie listing website where all the movies are displayed in sequence based on their #TITLE#. The webpage is generated automatically by the software using a template file. Here is the section of code in the template file that sho ...

Integrating blade code within blade code

Struggling to craft a button using the Form builder. {!! Form::button('<span style="color: {!! $colour[$i] !!}" class..') !!} The specific details of the button don't matter, all I wanted was to adjust the font color to $colour[$id]. Th ...

Stop the body from scrolling when the side panel is opened

Whenever I click on my button with the class "cd-btn," it triggers the toggling of my panel with the class "cd-panel.is-visible." jQuery(document).ready(function($){ //open the lateral panel $('.cd-btn').on('click', function(event){ ...

Enable scrolling of the background with ngb Modal

I need help figuring out how to remove the overflow: hidden style applied on <body class"modal-open"></body> This is related to using bootstrap 4 modals. I want the background to be scrollable. Thanks! Edit: I tried using renderer2 for An ...

Conditional statement based on the background color

Despite researching various topics on using background colors in if statements, I have yet to find a satisfactory solution. Whether I define an element as a variable beforehand or use rgb/rgba values, my code does not produce the desired results; it always ...

Deciphering the hierarchy of z-index stacking

I'm feeling a bit puzzled about how to determine the stacking order using z-index. I am struggling to grasp how browsers handle elements with the position property in comparison to those without it. Is there a set rule to establish the stack order o ...

Is there a way to enable ad-block plugins to effectively hide an entire div from visitors, preventing the website from appearing incomplete?

I have set up a div element specifically for ads, giving it some padding and a border to make it stand out. Surprisingly, this approach is not counter-productive. However, considering the percentage of users who use adblock, I am concerned that they will ...

Executing a series of HTTP requests sequentially using Angular 5

I need some guidance on sending an array of HTTP requests in sequential order within my application. Here are the details: Application Entities : Location - an entity with attributes: FanZone fanZone, and List<LocationAdministrator> locationAdmins ...

When deciding between utilizing a Javascript animation library and generating dynamically injected <style> tags in the header, consider the pros and cons of each

We are currently in the process of developing a sophisticated single-page application that allows users to create animations on various widgets. For example, a widget button can be animated from left to right with changes in opacity over a set duration. Ad ...

Having trouble with Angular 8 in IE11? Learn how to configure your Angular application to use ES6/ES2015

Every time I try to use my application on Internet Explorer, I encounter this error: Interestingly enough, the app functions perfectly fine on Chrome and Firefox. ...

Error message in Angular 2: Deletion operation is restricted

I am encountering an issue with the Angular 2 http.delete method. Below is my code snippet: const headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded'}); this.http.delete(ConstVarService.url + 'api/tasks/Usu ...

Detecting parent changes in Angular 2 child components

Currently, I am facing an issue with a component that displays a list of 'items' which are components created using a selector. I have a checkbox that I want to update the 'state' of all child components when clicked. Struggling to fin ...

Creating a mobile-responsive float-right image using bootstrap

There is an image positioned to the right, surrounded by text: <img class="img-responsive" style="float:right;" src="https://assets.ifttt.com/images/channels/1352860597/icons/on_color_large.png"> <p>Lorem ipsum dolor sit amet, consectetur adip ...

Is it possible to verify the compatibility of certain at-rules in CSS?

I am in search of a counterpart to @supports specifically for at-rules. I desire the ability to execute: @supports (@counter-style) { things } My goal is to achieve this using only CSS/HTML. Can anyone guide me on how to accomplish this task? ...

Navigating from a library to app components: A step-by-step guide

I successfully converted my login-component into a library, and now the first thing displayed in myApp is the login page. However, I'm facing an issue with navigating to the home page after a successful login. Can anyone provide guidance on how I can ...

Taking out the z-index from the transition code

Is there a way to restructure the code without needing to use z-index for the transition? Without z-index: https://jsfiddle.net/Legcb42d/ .container1 { position: relative; width: 100%; height: 100%; } .container1.slide { height: auto; min-heigh ...