简体   繁体   English

如何将此div放置到页面底部

[英]How to place this div to the bottom of the page

I'm stuck trying to make the footer stick to the bottom of the page.我一直试图让页脚粘在页面底部。

This is the basic layout:这是基本布局:

<div id="div-header"></div>     
<div id="div-body">
    <h2>Some content</h2>
    <div id="div-left">Left content</div>
    <div id="div-right">
        right content
    </div>
</div>
<div id="div-footer-bottom"></div>

And this is how I style the footer:这就是我设计页脚的方式:

#div-footer, #div-footer-bottom{
    background-color: red;
    border-top: 1px solid #CCCCCC;
    height: 40px;
    padding: 20px 30px;
    text-align: right;

}

#div-footer-bottom{
    position: relative;
    clear: both;
}

As you can see below, the page is rendered OK when the browser is zoomed at 100%:如下所示,当浏览器放大 100% 时,页面呈现正常:在此处输入图片说明

But if the browser is zoomed at 120%, for example, this is how the page is displayed:但是如果浏览器放大到 120%,例如,页面是这样显示的:

在此处输入图片说明

Please take a look at the full code in jsfiddle to discover what I am doing wrong, since I don't know what else to try:请查看 jsfiddle 中的完整代码以发现我做错了什么,因为我不知道还能尝试什么:

http://jsfiddle.net/RS88D/ http://jsfiddle.net/RS88D/

Thanks in advance.提前致谢。

Try adding the following css尝试添加以下css

#div-footer-bottom{
    position: fixed;
    bottom:0;
    left:0;
    clear: both;
    width:100%;
}

For overlapping对于重叠

Add margin-bottom to the div-left .margin-bottom添加到div-left Margin should be equal to the height of the footer (add padding pixels also).边距应等于页脚的高度(也添加填充像素)。 In your case在你的情况下

#div-left
{
  margin-bottom: 80px;
}

Update 24-Mar-2014 2014 年 3 月 24 日更新

For your first fiddle details just add the below and try,对于您的第一个小提琴详细信息,只需添加以下内容并尝试,

body, html
{
      height:100%;
}

And in the #div-body css, remove min-height: 490px;#div-body css 中,删除min-height: 490px; and add min-height: calc(100% - 190px);并添加min-height: calc(100% - 190px);

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

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