【发布时间】:2016-09-05 13:44:39
【问题描述】:
是的,关于 css 的另一个烦人的溢出问题...
这是我的情况:
HTML
<div id="parent">
<div id="child1">
Some short content that may take a line or two.
</div>
<div id="child2">
Some short to very long content that may overflow parent div...
</div>
<div>
CSS
#parent {
position: absolute;
height: 100%;
width: 100px;
}
#child1 {
}
#child2 {
overflow: auto;
}
如您所见,我希望 child2 在需要时溢出父 div。但是由于我不知道 child2 的确切高度(因为 child1 可能会有所不同),所以我无法像使用 bottom: 0px 和 top: ???px 那样进行一些绝对定位。
一些 JSFiddle 可以玩:https://jsfiddle.net/6r3ojecL/1/
在最坏的情况下,我会使用一些难看的 JS 代码 sn-p,但如果我能再次掌握 css,我会很高兴。 :)
谢谢!
【问题讨论】:
标签: css overflow positioning