question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sticky footer when using the side nav

See original GitHub issue

I am trying to add the material2 side nav to my home page that has a header, content and a sticky footer using flex, but I am having no luck. (example of sticky footer I’m using https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/)

Has anyone managed to do this and could point me in the right direction?

my current html

<div class="site">
 <md-sidenav-layout  class="site">
<header class="site-header">
  <md-sidenav #sidenav mode="over" class="app-sidenav" opened>
    <md-toolbar color="primary">
      <h2>Menu</h2>
    </md-toolbar>
    <md-nav-list>
      <a *ngFor="let navItem of navItems"
         md-list-item
         [routerLink]="[navItem.route]">
         <md-icon>{{navItem.icon}}</md-icon>
          {{navItem.name}}
      </a>
    </md-nav-list>
  </md-sidenav>

  <md-toolbar color="primary">
    <button md-icon-button (click)="sidenav.toggle()">
        <md-icon class="md-24" >menu</md-icon>
    </button>
  </md-toolbar>

</header>
  <div class="app-content site-content site-content--full">
    <router-outlet></router-outlet>
  </div>
  <footer class="site-footer">...</footer>

</md-sidenav-layout>

</div>

my css:


.site {
  display: flex;
  flex-direction: column;
  height: 100%; /* 1, 3 */
}

.site-header,
.site-footer {
  flex: none; /* 2 */
}

.site-content {
  flex: 1 0 auto; /* 2 */
  padding: var(--space) var(--space) 0;
  width: 100%;
}
.site-content::after {
  content: '\00a0'; /* &nbsp; */
  display: block;
  margin-top: var(--space);
  height: 0px;
  visibility: hidden;
}
@media (--break-lg) {
  .site-content {
    padding-top: var(--space-lg);
  }
  .site-content::after {
    margin-top: var(--space-lg);
  }
}

.site-content--full {
  padding: 0;
}
.site-content--full::after {
  content: none;
}
html,
body {
    height: 100%;
    margin: 0;
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
josh-lestercommented, Jan 13, 2017

@Codebacca @EladBezalel this works. You have to make sure you dont have the wrapper around the “side nav” menu elements

HTML:

<md-sidenav-layout>
      <md-toolbar color="primary">
        <span>
          <button md-icon-button (click)="sidenav.toggle()">
            <md-icon>menu</md-icon>
          </button>      
        </span>        
        <span class="fill-space"></span>
        <button md-icon-button [md-menu-trigger-for]="menu">
          <md-icon>more_vert</md-icon>
        </button>
      </md-toolbar>
      <md-menu x-position="before" #menu="mdMenu">
      </md-menu>
      <md-sidenav mode="side" #sidenav>
      </md-sidenav>
    <div class="site">
      <main class="content">
          <router-outlet></router-outlet>
      </main>
      <footer class="footer">        
      </footer>
    </div>
  </md-sidenav-layout>

CSS:

md-sidenav-layout{
    min-height: 100vh;
}
.site{
    display: flex;
    flex-direction: column;
    min-height: 93.5vh;
}
.content{
    flex: 1;
}
0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to keep footer from pushing up sticky sidebar
Move your footer from outside the section area into it and your navbar will keep being sticky to the bottom of the page....
Read more >
Scrollable sidebar with sticky footer using Flexbox - YouTube
Receive a monthly CSS nugget by email: https://codyhouse.co/newsletter CSS trick! Learn how to use Flexbox to create a scrollable sidebar ......
Read more >
Sidebar Issue and Sticky Footer - HTML & CSS - SitePoint
The trick is to contain your header ( which changes height from page to page), and your content in ONE wrapper, and make...
Read more >
[Question] Sticky footer in sidebar nav #2593 - GitHub
I am using the below currently but because of position: absolute it is overlapping the nav items when they are expanded. Note that...
Read more >
Bootstrap 5 sidebar example 2 (sticky footer)) on Codeply
Sticky position is used to make the sidebar appear fixed. A multi-level sidebar with collapsible menu items. The sidebar moves to horizontal top...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found