CSS - 页脚显示在错误的位置
CSS - Footer displayed in wrong position
我试图在另一个 div 的底部和内部显示页脚 div 但是当我使用以下代码时,黑色页脚显示在 div.
<div class="Background">
<div id="sitefooter">
<style>
#sitefooter {
position: relative;
bottom: 0px;
height: 130px;
background-color: black;
width: 100vw;
}
</style>
</div>
</div>
我也试过用这个改变它的位置:
position: absolute;
bottom: 0;
我的CSS背景如下:
.Background {
display: block;
margin-left: auto;
margin-right: auto;
width: 100vw;
height: 100vh;
background-image: url('resources/background.png');
background-size: cover;
background-position: center;
}
如果有人能提供帮助那就太好了。
谢谢
div.Background
必须有 position:relative
样式或 div 里面有 position: absolute
是行不通的。
.Background {
width:100%;
height:200px;
background:green;
position:relative;
}
#sitefooter {
position: absolute;
bottom: 0px;
height: 130px;
background-color: black;
width: 100%;
color:#fff;
}
<div class="Background">This is the outer div,
<div id="sitefooter">This is the inner div.</div>
</div>
我试图在另一个 div 的底部和内部显示页脚 div 但是当我使用以下代码时,黑色页脚显示在 div.
<div class="Background">
<div id="sitefooter">
<style>
#sitefooter {
position: relative;
bottom: 0px;
height: 130px;
background-color: black;
width: 100vw;
}
</style>
</div>
</div>
我也试过用这个改变它的位置:
position: absolute;
bottom: 0;
我的CSS背景如下:
.Background {
display: block;
margin-left: auto;
margin-right: auto;
width: 100vw;
height: 100vh;
background-image: url('resources/background.png');
background-size: cover;
background-position: center;
}
如果有人能提供帮助那就太好了。
谢谢
div.Background
必须有 position:relative
样式或 div 里面有 position: absolute
是行不通的。
.Background {
width:100%;
height:200px;
background:green;
position:relative;
}
#sitefooter {
position: absolute;
bottom: 0px;
height: 130px;
background-color: black;
width: 100%;
color:#fff;
}
<div class="Background">This is the outer div,
<div id="sitefooter">This is the inner div.</div>
</div>