纯css 实现footer sticker

发布于:2023-05-25 ⋅ 阅读:(52) ⋅ 点赞:(0)

希望footer一直在页面底部

css

html, body, #sticker {height: 100%;}
body > #sticker {height: auto; min-height: 100%;}
#stickerCon {padding-bottom: 40px;} 
#footer {margin-top:-40px; height: 40px; width: 100%; text-align: center;
line-height: 40px; color: #ABA498; font-size: 12px; background: #fafafa; 
border-top:1px solid #E7E7E7;}

html

<div id="sticker">
    <div id="stickerCon"></div>
</div>
<div id="footer">footer</div>

这样做的目的:当content的内容不能够撑起一个页面,底部信息会出现在页面某一位置,比如中部等,防止footer靠上。