我有一个 span
元素作为纯色背景,高度为300px . 我希望这个span块始终位于页面的底部,而不是当前正在发生的窗口/屏幕 . 有人能帮我吗?
html,
body {
min-height: 100%;
}
#wrapper {
margin: 0 auto;
max-width: 800px;
}
.blue-bg {
background: #049ae6;
bottom: 0;
display: block;
height: 300px;
position: absolute;
width: 100%;
z-index: -1;
}
<div id="wrapper">
<section id="content">
blah blah blah
</section>
</div>
<span class="blue-bg"></span>
内容将与底部附近的span元素重叠,如下所示:
2 回答
将
position: absolute;
更改为position: fixed
.https://www.w3schools.com/css/css_positioning.asp
UPDATE :
position: absolute
是正确的,但是:(https://www.w3schools.com/css/css_positioning.asp)
所以,我介绍了另一个位置为
relative
的包装元素(#page) .