How to implement the classic "sticky footer" with angular-material?
There's no need for a bottom-sheet or something like it.Leverage the flexbox behavior and you are good to go:
- Use
layout="column"
andlayout-fill
attributes on your main wrapper (can be yourbody
tag). - Create your sections:
header
,main
andfooter
. - Use
flex
attribute on yourmain
.
Check my example, based on @kuhnroyal pen.
You can get this to work with a small workaround.
- use
min-height: calc(100vh - 176px)
on yourmain
element, (176px = 2*88px for the md-toolbars) - remove the
layout='column'
from the root div - remove the
layout-fill layout='column'
from the body
I replaced the material css/js with CDN version 0.8.3 since my IE10 would crash with that amount of CSS/JS in a Codepen.
I tested this on Chrome, Firefox and IE10 - seems to work.
So I am just experiementing with angular-material but what I did for this was
<div layout="column" layout-fill> <md-toolbar class="md-default-theme"> <!-- your stuff --> </md-toolbar> <md-content layout-fill role="main"> <!-- your main areas --> </md-content> <md-bottom-sheet> <div>I am a sticky footer</div> </md-bottom-sheet></div>
I have not experimented enough to know for sure whether this does everything they way I want, but is so far looks promising. Note if you content is not constrained, it would likely continually push the bottom-sheet down. if you used a overflow-y: auto on the md-content it might work (I don't have enough of my app built yet to test)