CSS 在页面底部放置一个栏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4171446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Put a bar at the bottom of a page
提问by hd.
I need to put a fixed bar for showing a news title at the bottom of a page regardless of the page's height and device display height.
无论页面的高度和设备显示高度如何,我都需要在页面底部放置一个用于显示新闻标题的固定栏。
How can I do that using CSS?
我怎样才能使用 CSS 做到这一点?
回答by Dan Grossman
Set this bar's position property to fixed, and its bottom and left coordinates to 0. Set a high z-index so that it appears over top of whatever other content is at the bottom of the page at a given time. It will then stay stuck to the bottom of the browser window.
将此栏的位置属性设置为固定,并将其底部和左侧坐标设置为 0。设置一个高 z-index,以便它在给定时间出现在页面底部的任何其他内容的顶部。然后它将停留在浏览器窗口的底部。
#someidentifier {
position: fixed;
z-index: 100;
bottom: 0;
left: 0;
width: 100%;
}