0

我遇到了无法将版权页脚移到页面底部的困境,目前它坚持在我的页面中间,因为某种原因,当我尝试在谷歌浏览器中检查元素时它告诉我我的容器只有 471px 的高度(我屏幕的一半)....但是我没有在代码中的任何地方限制我的高度,只有 100% 的最小高度,所以我很茫然.. 任何帮助将不胜感激. 谢谢 :)

我会发布一张图片,但我需要 10 次重复……才能做到这一点……

这些是我的 CSS:

html, body{
height:100%;
}

body {
font-family: '', sans-serif;
font-size:16px;
color:#33767d;
text-align:left;
background-image:url();
background-repeat:no-repeat;
background-color:#FFF;
position:relative;
margin:0;
}

#container {
float:none;
margin:0px;
width: 85%;
margin-top:20px;
position:relative;
margin-bottom:0;
min-height:100%;
}

#footer {
position:absolute;
width:auto;
text-align:center;
font-size:8px;
color:#54c0cc;
font-family:'', sans-serif;
text-transform:uppercase;
top:100%;
left:40%;
height:60px;
}

和我的 HTML:

<body>
<div id="container">

--> 徽标和导航栏和联系信息在这里

<div id="footer">
    All Images &#169; 2013 . All Rights Reserved. 

</div>  //div end footer

</div>  //div end container

</body>
4

4 回答 4

1

您可以使用 javascript 将页脚保留在页面底部,只需计算窗口的高度和页脚的高度

我已经更新了代码,请使用它。

<script>
var windowheight = $(window).height();
var footerheight = $(footer).height();
var maincontentheight = windowheight-footerheight
$("#container").css({'height':maincontentheight +'px'});
</script>
于 2013-08-30T12:19:15.363 回答
0

不,您必须将代码放在标题(头部)部分

<script>java script code will be heer<script>
于 2013-09-02T06:42:33.850 回答
0
<script>
var windowheight = $(window).height();
var footerheight = $(footer).height();
var maincontentheight = windowheight-footerheight
$("#container").css({'height':maincontentheight +'px'});
</script>

请使用此代码

于 2013-09-02T06:48:37.177 回答
0
#footer {
    position:absolute;
}

您需要首先删除它,因为您的页脚不在主布局中,然后对其进行调整。

于 2013-08-30T07:33:16.217 回答