简体   繁体   English

flexbox布局,左侧有两个项目,右侧有一个项目

[英]flexbox layout with two items on the left and one on the right

I am trying to achieve the following layout with flexbox. 我正在尝试通过flexbox实现以下布局。

┌─┬─────┐
│A│     │
├─┤  C  │ 
│B│     │
└─┴─────┘

Is it possible to do so without wrapping A and B into a wrapper? 是否可以在不将A和B包裹到包装纸中的情况下这样做?

Yes, it's possible. 是的,有可能。 Take in account that in this example the main container has a fixed width and height. 考虑到在此示例中,主容器具有固定的宽度和高度。

 #container{ height: 200px; width: 300px; display: flex; flex-flow: column wrap; } #container, #A, #B, #C{ box-sizing: border-box; border: 1px solid black; } #A{ height: 50%; width: 100px; } #B{ height: 50%; width: 100px; } #C{ height: 100%; width: 200px; } 
 <div id="container"> <div id="A">A</div> <div id="B">B</div> <div id="C">C</div> </div> 

unfortunately, there is no fixed height, so I ended up with doing things old way — via tables, like this 不幸的是,没有固定的高度,所以我最终还是用旧的方式做事-通过桌子,像这样

HTML: HTML:

<div id="container">
   <div id="A">A<br>AAA<br>BBB</div>
   <div id="B">B</div>
   <div id="C">C</div> 
</div>

CSS: CSS:

#container {
   width: 100%;
   outline: 1px solid black;
   display: table;
}

#A,#B,#C {
   outline: 1px solid crimson;
}

#A,#B {
  width: 100%;
}

#C {
   display: table-cell;
   vertical-align: middle;
   width: 50%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM