相关疑难解决方法(0)

一个弹性项目设置兄弟姐妹的高度限制

我有两个兄弟元素,每个元素都包含动态内容.

<div class="flex">
    <div class="sibling-1"></div>
    <div class="sibling-2"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

在某些情况下sibling-1会有更多内容sibling-2,反之亦然.我希望第二个元素sibling-2的高度始终等于第一个元素的高度sibling-1.如果高度sibling-2大于那么sibling-1它的高度将溢出flexdiv,因此可以滚动.

有没有办法用Flexbox实现这一目标?

html css css3 flexbox

27
推荐指数
2
解决办法
1万
查看次数

限制flexbox项目的高度

我有一个带有2个项目的flexbox,direction = row.第二项的文本内容很长.我希望第二项与第一项一样高,并有一个滚动条.这可能吗?

#wrap { display: flex; }
#item-1 { height: 100px; background: orange; flex: 1; }
#item-2 { overflow: scroll; flex: 1; }
Run Code Online (Sandbox Code Playgroud)
<div id='wrap'>
  <div id='item-1'></div>
  <div id='item-2'>  
I would like this text to have a scrollbar, and thus not take up more height than the orange box.<br> I would like this text to have a scrollbar, and thus not take up more height than the orange box.<br> I would like this text to have a scrollbar, and …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×2

flexbox ×2

html ×2

css3 ×1