创建位于屏幕下方的页脚元素 [英] Create footer element located beneath the screen
本文介绍了创建位于屏幕下方的页脚元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个页面不填满整个屏幕的高度,但我想要一个页脚停留在屏幕下方,以便在开始滚动时显示,无论用户的屏幕高度如何。
I have a page that does not fill the entire screen's height, but I want a footer to stay just below the screen, so that it appears right when you start scrolling - no matter the person's screen height.
如何使用CSS完成此操作?
How do I accomplish this using CSS?
EDIT
我试过:
#footer{
position:absolute;
left:0px;
top:100%;
}
这可以工作,但如果我的页面 浏览屏幕的高度。
This works, but it gets in the way if my page does go over the screen's height. I really need compatibility for both types of pages.
推荐答案
这里是一个简单的布局示例:
Here's a simple example of the layout you describe:
HTML
<html>
<head><title>Hidden Footer</title></head>
<body>
<div id="content">
Content here
</div>
<div id="footer">
Footer here
</div>
</body>
</html>
CSS
html,
body { height: 100%; min-height: 100%; }
#content { min-height: 100%; }
#footer { background: #ccc; }
这篇关于创建位于屏幕下方的页脚元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文