html - Fixed Footer, with Overflowing Body? -
using bootstrap responsively designed web-app, looking replicate typical mobile-app layout:
fixed navbar
+ overflowing body
+ fixed footer
check out smartphone preview (right-side icon) of: http://www.bootply.com/124373
i have following css, close, fixed footer cuts-off body - instead of body scrolling:
html { position: relative; min-height: 100%; } body { /* margin bottom footer height */ margin-bottom: -60px; } #footer { position: absolute; bottom: 0; width: 100%; /* set fixed height of footer here */ height: 60px; background-color: #f5f5f5; } body > .container { padding: 60px 15px 0; } .boxes { margin-bottom: 22px; } .middle { margin-top: 4%; overflow: auto; }
and here's html:
<!-- fixed navbar --> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#">mobile app format replication</a> </div> </div> </div> <!-- begin page content --> <div class="container middle"> <div class="row boxes"> <div class="col-xs-6 col-md-6"><img src="http://placehold.it/125"></div> <div class="col-xs-6 col-md-6"><img src="http://placehold.it/125"></div> </div> ... <div class="row boxes"> <div class="col-xs-6 col-md-6"><img src="http://placehold.it/125"></div> <div class="col-xs-6 col-md-6"><img src="http://placehold.it/125"></div> </div> </div> <!-- fixed footer --> <div id="footer"> <div class="container"> <p class="text-muted">fixed footer content</p> </div> </div>
what using position: fixed
on footer element, , removing negative margin on body (instead, use 60px bottom padding instead):
#footer { position: fixed; bottom: 0; width: 100%; height: 60px; background-color: #f5f5f5; } body > .container { padding: 60px 15px; }
see fork here: bootply
Comments
Post a Comment