如何使这个嵌套页脚粘在底部?
我一直在尝试一些不同的事情,但我不确定如何使该页脚粘在底部。困难的出现是因为有许多彼此嵌套的 div。 我想要实现的目标是让右边框和左边框包装器转到页面底部以包围页脚,但页脚应该位于页面底部。
解释一下所有嵌套的 div:主体应用了主要的平铺背景图像,#background 有一个透明的覆盖层,使其向边缘淡出。 border-right 和 border-left div 有一个重复图像作为背景,充当内容 div 的边框。
我知道页脚 div 应该完全独立,但是当我制作它时,它会保持在窗口宽度的中心,而不是左边框的宽度,所以当屏幕缩小时它看起来很奇怪。
基本页面结构如下,我还发布了一个jsfiddle: http://jsfiddle.net/cutcopypaste/zry4T/
<body>
<div id="background">
<div id="container">
<div id="header">
<div id="logo"></div>
<div id="menu">
<p>Menu</p>
</div>
</div>
<div id="border-left">
<div id="border-right">
<div id="content">
<p>Page Content</p>
</div>
</div>
</div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</div>
</body>
I've been trying a few different things and I'm not sure how to make this footer stick to the bottom. The difficulty comes because there are a number of nested divs inside one another.
What I want to achieve is have the border-right and border-left wrappers go to the bottom of the page to surround the footer, but the footer should be at the bottom of the page.
to explain a bit all the nested divs: the body has the main tiling background image applied to it and #background has a transparent overlay that makes it fade out toward the edges.
the border-right and border-left divs have a repeating image as background that serves as borders to the content div.
And the footer div should be totally separate I know, but when I make it so it stays centered to the width of the window rather than the width of the border-left so it looks wonky when the screen gets shrunk down.
Basic page structure is as follows and I have also posted a jsfiddle: http://jsfiddle.net/cutcopypaste/zry4T/
<body>
<div id="background">
<div id="container">
<div id="header">
<div id="logo"></div>
<div id="menu">
<p>Menu</p>
</div>
</div>
<div id="border-left">
<div id="border-right">
<div id="content">
<p>Page Content</p>
</div>
</div>
</div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</div>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的解决方案: http://jsfiddle.net/zry4T/15/
My solution: http://jsfiddle.net/zry4T/15/
这是否为您指明了正确的方向?
http://jsfiddle.net/zry4T/28/
我基本上将页脚绝对放在了包装纸底部,并确保包装纸至少与内容物一样高。
编辑:更新了小提琴
Does this point you in the right direction?
http://jsfiddle.net/zry4T/28/
I've basically placed the footer absolutely at the bottom of the wrapper, and made sure the wrapper is at least as tall as the content.
EDIT: Updated fiddle