我的页面中的最终祖先div在所有四个边上都需要一个边距,以赋予它一个面板效果。这里是我的代码:
CSS:在高度100%处保持div的边距
html, body {
height: 100%;
}
#wrapper {
width: 100%;
height: 100%;
}
#bibletree {
width: 20%;
float: left;
height: 100%;
}
.inner { /*this is the div that I need a margin around, so it is by 10px of the #bibletree div on all sides, including the bottom.*/
overflow: auto;
}
HTML:
<div id="wrapper">
<div id="bibletree">
<div class="inner">my content here, both short and long</div>
</div>
</div>
正如你可能猜到了,有很多更比这里写的是什么回事。我有几列divs,在.inner
div上面板效果都需要这个边距。谢谢你的帮助。
顺便说一句,我已经尝试绝对定位,它只基于窗口,而不是父元素,即使我将父母设置为position: relative
位置。
我做了你提到的第二件事,它根据窗口定位'.inner',* not * parent。 – preahkumpii
查看@Sjoerd在这里说的内容的工作示例,http://jsfiddle.net/z6UTV/ –
此外,我不能做边界的想法,因为当它溢出时,滚动条就是*内部*边界。 – preahkumpii