简体   繁体   English

固定页脚和相对DIV

[英]Fixed footer & relative DIV

I am soo confused right now. 我现在很困惑。 Coding really isn't my thing, so I believe that I messed up majorly somewhere which creates this problem: 编码确实不是我的事,所以我认为我主要是在某个地方搞砸了,从而造成了这个问题:

I'm trying to make a sticky footer. 我正在尝试使页脚变粘。 The footer does stick--but only if I make my main content DIV (the white centered box) relative. 页脚确实会粘住-但前提是我将主要内容DIV(白色居中框)设为相对位置。 I need the height of that DIV to stretch with the content (which will contain a PHP script that'll pull from my Wordpress blog--so naturally, I need it to adjust as necessary). 我需要DIV的高度来扩展内容(它将包含一个PHP脚本,该脚本将从我的Wordpress博客中提取-因此,很自然,我需要对其进行必要的调整)。 If the DIV stretches longer than 500px, there's a weird two-scrollbars things going on, & I hate that. 如果DIV拉伸的长度超过500像素,则说明发生了奇怪的两卷滚动条,我讨厌这样做。 I like the relative DIV, but I would love to rid of all the extra scroll space, as well as making sure it stetches/regresses with content & the footer stays where it is. 我喜欢相对的DIV,但我希望摆脱所有多余的滚动空间,并确保它随内容拉伸/退回并且页脚保持在原处。

I hope that's not too confusing. 我希望不要太困惑。 I'd just like someone to look over my source code & see where I'm going wrong. 我只希望有人查看我的源代码并查看我要去哪里。 Thank you for any help. 感谢您的任何帮助。

http://www.missa.me/practice3.php http://www.missa.me/practice3.php

nice website :) 不错的网站:)

You need to make the footer fixed, 您需要固定页脚,

use this CSS 使用此CSS

#footer {
position: fixed;
height: 80px;
clear: both;
background-color: #fff;
bottom: 0;
left: 0;
right: 0;
}

and take overflow: auto; 并采取overflow: auto; off of #main 脱离#main

what this does is tell the footer to stay 'fixed' to the bottom of your viewport, so it will always stick to the bottom of your screen.. and taking overflow:auto; 这样做是告诉页脚“固定”在视口的底部,因此它将始终固定在屏幕的底部overflow:auto; off will give your #main the natural ability to expand it's height depending on the content inside it. off将使您的#main天生具有根据其内部内容扩展其高度的自然能力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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