我如何在 twitters bootstrap css 框架中正确定位绝对 div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9898814/
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 do i properly position absolute divs within twitters bootstrap css framework
提问by Brian
I can't seem to get a div to absolutely position within its parent using the twitter bootstrap framework. I have a series of rows that follow a scheme as follows
我似乎无法使用 twitter bootstrap 框架将 div 绝对定位在其父级中。我有一系列遵循以下方案的行
<div id='wrapper'>
<div class='row-fluid'>
<div class='span2'>some content here</div>
<div class='span9'>other content to the side of the first div</div>
<div class='timestamp'>123456 this should align to the bottom right of wrapper</div>
</div>
</div>
css
css
.timestamp{
position:absolute;
bottom:0px;
right:0px;
}
But the timestamp div always positions itself to the absolute of the body of the whole dom document ignoring any intermediate divs. Any ideas what is causing this?
但是时间戳 div 总是将自己定位到整个 dom 文档正文的绝对位置,而忽略任何中间 div。任何想法是什么导致了这种情况?
回答by Nic Meiring
Your css should include
你的 css 应该包括
#wrapper {
position: relative;
}
The default positioning is static.
默认定位是静态的。
check out this article: http://css-tricks.com/absolute-positioning-inside-relative-positioning/
看看这篇文章:http: //css-tricks.com/absolute-positioning-inside-relative-positioning/