I'm looking for a way to make a div sticky to the bottom, like a footer, but inside a bootstrap grid, so not over the whole width.
Bootstrap has an example of a sticky footer, I tried to tweak it to make it work in my case but couldn't.
This is another approach, but also assumes your sticky div is not nested inside another div.
Below is my code, I need to make .app-footer
sticky to the bottom over the width of it's parent div.
<div class="row main">
<div class="col-xs-2 col-md-4 col-lg-5">...</div>
<div class="col-xs-8 col-md-4 col-lg-2">
<div class="app"></div>
<div class="app-footer"></div>
</div>
<div class="col-xs-2 col-md-4 col-lg-5">...</div>
</div>
Edit: the CSS I've tried but doesn't work:
html,
body {
height: 100%;
}
/* Wrapper for page content to push down footer */
.app {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
.app-footer {
height: 60px;
background-color: #f5f5f5;
}
Edit: Ok, got it. The solution seems to be to add {position: relative; height: 100%} to ALL parent divs. In my case I had the grid wrapped in <div class="row">
, when I added it there too it worked.