创建一个扩展为包含一个块的div,但让另一个块流到它之外

时间:2014-09-19 01:44:47

标签: css overflow block

CSS总是抓住我......

我希望有一个块自动扩展以包含一些子内容,但让另一个孩子流出它。那就是:

<div class='no-expansion-from-big-child'>
  <p>This is a block with content, and a child div.</p>
  <div class='big-child'>
    <p>This is a child-block - I want it to overflow outside the borders of its containing div.</p>
  </div>
</div>

因此,如果我的包含div的边框,我希望它扩展为包含&#34; p&#34;阻止,但允许大孩子&#39; div延伸到边界之外。

似乎应该很简单......

1 个答案:

答案 0 :(得分:0)

我不确定这是否真的是你正在照顾的,但是你可以浮动第二个子div并给容器一个overflow visible以确保它赢了t包含浮动的子项:

.no-expansion-from-big-child {
  border: 1px solid red;
  overflow: visible;
}

.big-child {
  float: left;
}
<div class='no-expansion-from-big-child'>
  <p>This is a block with content, and a child div.</p>
  <div class='big-child'>
    <p>This is a child-block - I want it to overflow outside the borders of its containing div.</p>
  </div>
</div>