简体   繁体   中英

How to create a footer that is always the last thing on the page using float layout

就像问题陈述一样,如何将页脚div保持为使用float布局在页面上显示的最后一个元素,而不管页脚前面的内容量。

place the following at the end of your code (before </body> )

<div id="footer">Footer</div>

Add the following to your stylesheet:

#footer{ clear:both; }

这是我用来将页脚保持在页面底部的解决方案。

What Angelo R. said should work but it may depend on the rest of your structure. If you for example have some kind of a holder with n floated elements inside and you set the last element (your footer) to have no float and clear:both it should clear the above floats and seat on the bottom. The other example might be that you have some floated elements inside a holder and the footer is beneath and outside that holder you should make sure that the elements inside that holder are cleared by adding overflow:hidden to that holder or use some kind of clearfix, because if the floats that holder contains are not cleared he will collapse no mater what property you add to your footer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM