css - 页脚没有扩展

The*_*iot 1 css footer

我对css很新,我仍然很难理解一些概念,特别是定位.无论如何,我的问题是,当我设置position: relative;容器和页脚时position: absolute; bottom: 0; ,页脚变小.它与我放置这些代码之前应该是容器的宽度相同.我这样做是因为我希望我的页脚位于容器的最底部.

以下是截图:

在此输入图像描述

栗色是页脚.

在我的页脚中,我不使用div,而是使用html元素<footer>.

我的css代码:

div#container {
    height: 100%;
    width: 1000px;
    margin: auto;
    background-color: #C9C9C9;
    position: relative;
}

footer {
    background-color: #340B09;
    height: 50px;
    position: absolute; 
    bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)

请帮忙.

tse*_*ium 5

添加宽度:1000px; 到你的页脚