I'm trying to add a sticky footer to the Polymer Starter Kit. So far I've tried
core-header-panel and sticky footer and http://www.jlmiller.guru/jekyll/2015/06/02/sticky-footer.html
but neither seem to work.
How do you add/style a sticky footer to a paper-header-panel?
<paper-header-panel class="flex">
<paper-toolbar>
<div>Paper-Toolbar</div>
</paper-toolbar>
<div class="content fix fullbleed layout vertical">
<iron-pages attr-for-selected="data-route" id="pages" selected="home">
<section data-route="home" class="layout vertical center">
<paper-material>This is some content for home
<br />
<br />
<br />
<br />
</paper-material>
<paper-material>This is some other content for home</paper-material>
<paper-button id="btn1" raised>Next Iron Page</paper-button>
</section>
<section data-route="page1" class="layout vertical center">
<paper-material>This is content for Page 1</paper-material>
<paper-button raised>Button to move to Home</paper-button>
</section>
</iron-pages>
</div>
<!-- content -->
<footer>
Sticky footer?
</footer>
</paper-header-panel>
Plunker http://plnkr.co/edit/wOxCgExdWdJdhhfQ4xBz?p=preview
To do this just remove margin top from footer and set margin top and bottom to auto margin: auto 0; on your main content (in my case article element) or margin: auto; to center it on both direction (vertically and horizontally) and it will make content align to center.
Quick answer: Add “display:flex; flex-direction:column; min-height:100vh;” to body or appropriate layout body element, then add “flex:1;” to content wrapper element/section.
Make Footer Sticky To make your footer stick to the bottom of the viewport, add classes d-flex , flex-column , and h-100 to the body tag. Also add class h-100 to <html> tag.
One way is to use position:fixed
.
<footer style="position:fixed;bottom:0">
Sticky footer?
</footer>
Or you can move the footer
outside of the paper-header-panel
and wrap both of them in a vertically stacked div
.
<div class="fit vertical layout">
<paper-header-panel class="flex">
...
</paper-header-panel>
<footer>
Sticky footer?
</footer>
</div>
Note that on the root div
I have used fit
to make its content fill the entire page and vertical layout
to stack the content vertically.
See this plunker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With