-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sticky footer #306
Comments
Agreed |
You can make the footer sticky pretty easily using this method: http://ryanfait.com/resources/footer-stick-to-bottom-of-page/ |
Thanks - will take a look at this tonight.. ! :) -----Original Message----- You can make the footer sticky pretty easily using this method: http://ryanfait.com/resources/footer-stick-to-bottom-of-page/ Reply to this email directly or view it on GitHub: |
Going to skip on this one—easy to add on with a limited about of CSS. If we get any more requests, we'll revisit. |
It would be nice if this was just part of the css ... maybe similar to container and container-fluid ... something like footer and footer-sticky. |
+1 |
Just add I did it on a project recently (that's unfortunately not live yet, so can't demonstrate) and it really isn't too much trouble. Bootstrap is meant to be a starting point; you are allowed to add your own CSS on top! EDIT: A more complete example, just to demonstrate how simple it is: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
<style>
.container[role="main"] {
padding-bottom: 60px;
}
.bottombar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<div class="container" role="main">
<!-- your content -->
</div>
<div class="bottom-bar">
<div class="bottombar-inner">
<div class="container">
<ul class="nav">
<li><a href="#">Link 1</a></li>
</ul>
</div>
</div>
</div>
</body>
</html> |
@martinbean thanks :) |
Wouldn't this method cause the footer to always be visible? The method I suggested pushes the footer to the bottom if there is a small amount of content on the page, but if there is a lot of content the footer gets pushed "below the fold" so to speak. That way it isn't floating on top if the page scrolls. |
Sorry, I thought the issue was you wanted a static bottom bar like there is a static top bar. Even then, it isn't that much code to add to achieve a sticky footer as @markdotto says. Why not write your own styles for it so it only applies if your |
That's a good idea. I will try that at some point. |
I used a combination of the technique found in http://jsdo.it/Bakey/bootstrap-sticky-footer and http://ryanfait.com/resources/footer-stick-to-bottom-of-page/. For my html/haml I had something like:
For the scss it was:
I think the topbar made this a pain to implement because of the $topbar-height padding. I also have a trial-and-error 10px in the margin calculation of the .main style. It would be really nice to get an official or clean implementation that works with and without the topbar. |
in agreement, sticky footer would be killer addition. |
FWIW, I've spent a few hours trying to make an existing sticky footer implementation work with bootstrap (ryanfait's one) and it's being completely thrown off by bootstrap. |
I also have tried and handful of different combinations of the above techniques with no simple solution. It seems to me that at this point it is clearly complex enough to build into the core and have it fully supported. Just my opinion |
What exactly are the problems people are facing trying to implement a sticky footer with Bootstrap? I haven't try myself yet but don't see why it would be so difficult? |
@martinbean: I think people in this thread are looking for two different things
ryanfait's, listed above, does the latter, but is broken by bootstrap. I couldn't make it work - I think because of the 100% in the body, and the offsets and margins used by bootstrap. (I'm sorry I have no more details, I've forgotten it). @dteoh's implementation above, I think, does the former, and I got it to work with a bit of hacking after hours of trying to make ryanfait's one work. But this is not ideal - it covers content, which is not what my company footer should do. |
For a fixed footer (i.e. Facebook's) you just need to replicate the styles used in For a 'sticky' footer (i.e. Ryan Fait's) I'm not sure without having a crack at it myself. I'll see if I can find some time in the next couple of days to have a go. |
I have a version of the fluid layout working with a sticky footer in my fork of the bootstrap repo. It's in examples/sticky.html and requires the sticky.css file in addition to bootstrap.css. Does anyone see anything that could be improved there? Since the body needs padding: 0px for the sticky footer solution to work, I added a class to the container that includes padding to push the content down below the fixed topbar. https://github.com/dvanderbeek/bootstrap/blob/master/examples/sticky-footer.html |
@dvanderbeek I played around with your solution and it seems to be working nicely with and without the topbar. |
@dvanderbeek your link goes to a 404, and I didn't find the file in your repo -I am kinda new to GitHub browsing-, could you please update it? Thanks. |
I think I overwrote my whole bootstrap repo to clean it up because I had overwritten a lot of stuff and wanted the newest updates from the main repo. I just added a sticky footer example that I believe is the same as what I had before. Available here: https://github.com/dvanderbeek/bootstrap/blob/master/examples/sticky.html |
I worked out a solution myself, but thanks anyway :) May be I will post it here with the others as soon as I will catch up with some work deadlines. Cheers. |
Sticky footer would be a really useful addition to Bootstrap. |
+1 |
+1 There is already a |
Would mena that dropdown should also do dropup |
This isn't about having a "fixed" navbar, it is about having the footer always at the very bottom of the page. If you screen is 1000px tall, and you only have 100px of content at the top, the 200px footer you have should still be at the bottom of the screen so that you don't end up with 700px of white below the footer |
+1 |
You don't need the "spacer". although Martins solution works fine its less two tricks to it. make the wrapper min-height: 100%; Make body, html { On Thu, Sep 13, 2012 at 8:19 AM, Martin Bean [email protected]:
|
I have tried several of the solutions presented above, and my issue is with the 20px body padding imposed by Responsive Bootstrap. Applying negative left and right margins to the footer causes a horizontal scroll. Any suggestions, other than overriding this manually with javascript when the responsive layout is triggered? I love Bootstrap, but I would vote to have this feature added. People like me don't know the appropriate way to do things. Convention over configuration. If a simple fixed navbar warrants inclusion, I would expect a sticky footer (particularly because of the 20px padding issue - caused by Bootstrap). |
@micahalcorn an easy way to do have a sticky foot would be to do something like the following.. Make sure this goes right before the <footer class="page-footer">
<div>Content here would be your floating footer element, the paddings on the div in css keep it off the sides</div>
</footer> footer.page-footer {
border-top:1px solid #ccc;
background:#fff;
width:100%;
position:fixed;
top: auto;
bottom: 0;
}
footer.page-footer div {padding:10px 50px;} |
@Yohn |
Just to let every one know, I've updated my Bootstrap with Sticky Footer example page at http://www.martinbean.co.uk/bootstrap/sticky-footer/ to work nicely with responsive layouts. |
@martinbean Your implementation causes that there is always a scrollbar, or at least in Chrome.. |
@koenpunt I developed it in Chrome. There’s a vertical scrollbar because the content exceeds the page length. The sticky footer works as required with less content. |
@martinbean You have 2x #wrap, instead of #push and #wrap in your sample. |
@barryvdh Yeah, noticed a mark-up issue. Should be fixed now, with an option to toggle the code (code's hidden by default to display sticky footer implementation). |
@martinbean if you give your footer a background, you can see that the 20px body padding is enforced when you reduce the window size. Here is a screenshot => https://github.com/micahalcorn/images/blob/master/ss.png |
@micahalcorn Easily solved by applying negative left and right margins to the footer, and adding left and right padding to re-indent the content, as per the updated link: http://www.martinbean.co.uk/bootstrap/sticky-footer/ |
@martinbean I was attempting this without the @media condition, which resulted in a horizontal scrollbar. Simple enough, thanks so much. |
@martinbean fyi your sample code does not match up with example css. you have a #wrap not #push in the bottom div before the footer. you dont use '#footer' but 'footer'. etc |
@thezoggy Does the implementation work for you though when you amend those couple of things though? |
@martinbean yes |
@thezoggy Cool. I’ve updated the sample code. Thanks for pointing that out. |
@martinbean you should submit your code to http://bootsnipp.com/submit in addition to keep advertising it here. It would really help some people. At this point, it's clear it would be very tricky to add sticky footer component to Bootstrap that works in all scenario without javascript. Someone suggested earlier in this thread that your code should be added to Bootstrap docs, +1 for that. |
Thanks, @mtanvir. I'll submit to Bootsnipp later today. As for including the code in the Bootstrap docs, I'll leave it up to @fat and @markdotto to decide that. If they do though, then I'm more than happy to write something up. |
Added as an example in 2.1.2-wip after Martin emailed me about it. Thanks folks! |
Thank you very much! I read the full post to come here: http://twitter.github.com/bootstrap/examples/sticky-footer.html |
It would be a nice to have a note in the documentation on if/how this is compatible with static/floating navs |
I agree with @saulshanabrook, it would be nice to have an example / documentation regarding use with a fixed navbar included as well. |
.fixed-footer {bottom:0; left:0; position:fixed; height:50px; width:100%; margin:0; padding:10px} |
You should use the sticky footer supplied in 2.2.1 Sent from my iPhone On 6 Dec 2012, at 02:52 PM, Jarrett Vance [email protected] wrote:
|
It comes with the current bootstrap template. No CSS manipulation needed. |
@jarrettv thank you! |
Just want to say thank you Martin and everyone in this discussion |
It'd be good if Bootstrap supported sticky footers (floats to bottom of page for pages shorter than the browser window).
The text was updated successfully, but these errors were encountered: