3 回答

TA貢獻1876條經驗 獲得超6個贊
我想創建一種放置在底部的 div,當用戶滾動時,它會繼續跟隨頁面,有點像粘性內容。
你可以用position:sticky它來粘在底部......這是“有點像粘”
#content {
height: 800px;
border: 1px solid red;
}
#bottom {
border: 1px solid blue;
width: 100%;
background-color: #CCC;
text-align: center;
position: sticky;
bottom: 0;
}
<div id="content">
</div>
<div id="bottom">
bottom
</div>
如果您愿意,可以小提琴: https: //jsfiddle.net/c0me5d63/
如果您不想/不能使用position:sticky
那么您可以使用position:fixed
#content {
height: 800px;
border: 1px solid red;
margin-bottom:1.5em;
}
#bottom {
border: 1px solid blue;
width: 100%;
background-color: #CCC;
text-align: center;
position:fixed;
bottom:0;
}
<div id="content">
</div>
<div id="bottom">
bottom
</div>
添加回答
舉報