首页 文章

页脚放置,不在窗口底部,而是在内容的底部

提问于
浏览
0

我曾经有过这个模板,它的页脚就像这样

footer{
position: absolute;
bottom: -3em;
left: 0;
right: 0;
font-size: 12px;
text-align: center;
text-shadow: 1px 1px 1px rgba(0, 0, 0, .8);
color: rgb(160, 160, 160);
}

我正在使用php来获取动态内容但是,每当我的内容(包含在div中,就在页脚之前)发生变化时,它会改变它的长度(高度),这个页脚突然改变它的位置并突然放在顶部附近(最高)网页上的div)div .

我想知道如何让这个页脚停留在页面的底部,我正在寻找一个,但我刚发现{postition:fixed;},我本来打算将我的页脚“作为最后一个内容,在底部”不是“留在屏幕/窗口的底部”..

有人可以帮忙吗?提前致谢

1 回答

  • 0

    如果你的CODE很像,那么你很高兴

    HTML

    <div class="wrapper">
        <div class="footer">Lorem Ipsum</div>
    </div>
    

    css

    .wrapper{
        position:relative; background:grey;
        height:200px    
    }
    .footer{
    position: absolute;
    bottom: -3em;
    left: 0;
    right: 0;
    font-size: 12px;
    text-align: center;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, .8);
    color: rgb(160, 160, 160);
    }
    

    DEMO

    更改 wrapper 高度以查看差异

相关问题