jQuery 如何制作一个漂浮在页面底部的浮动div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18050763/
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
how to make a floating div that will float at the bottom of page
提问by manishkr1608
I want to make a floating div that will sit at the bottom of the page if bottom of current page is above window screen otherwise it will sit just above windows screen taskbar and if we scroll the page it will maintain its current position.
我想制作一个浮动 div,如果当前页面的底部在窗口屏幕上方,它将位于页面底部,否则它将位于窗口屏幕任务栏上方,如果我们滚动页面,它将保持其当前位置。
回答by icodebuster
You need to use position: fixed
你需要使用 position: fixed
#footer {
position: fixed;
bottom: 0;
width: 100%;
}
Here's the fiddle: http://jsfiddle.net/uw8f9/
这是小提琴:http: //jsfiddle.net/uw8f9/
回答by San
try this style for your floating DIV
为您的浮动 DIV 尝试这种风格
{
display:block;
position:absolute;
float:left;
bottom:0px;
left:20px;
}