我正在尝试在移动浏览器的屏幕底部显示固定页脚。我试过将位置:固定在页脚 ID 中。但是,它仍然无法正常工作。如何将页脚设置为在用户向下滚动页面时持续显示?
#footer {
color: #333333;
font-size: 70%;
font-style: italic;
text-align: center;
padding: 0;
position: fixed;
}
最佳答案
这样做:
#footer {
color: #333333;
font-size: 70%;
font-style: italic;
text-align: center;
padding: 0;
position: fixed;
bottom: 0px;
width: 100%;
}
'bottom: 0px' 会将页脚固定在屏幕底部,'width: 100%' 会将页脚内容居中。您还必须添加背景颜色,这样您的页面内容就不会通过页脚显示出来。
另外,正如@Adrift 所说,从页脚区域删除额外的关闭 div 标签。
关于css - 通过媒体查询在移动设备上显示固定页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23840311/