css – 带有表子的flexbox

前端之家收集整理的这篇文章主要介绍了css – 带有表子的flexbox前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个基于flexBox的布局,我希望看起来像这样:

  1. _______________
  2. | top banner |
  3. |---------------|
  4. | tabular data |
  5. | |
  6. |_______________|

随着表格数据占据横幅之后可用的任何大小.

如果B是display:block,则无效,如果是display:table则不行(参见http://jsfiddle.net/E4Qbw/).

  1. .container {
  2. display: -webkit-flex;
  3. -webkit-flex-flow: column nowrap;
  4. position: absolute;
  5. top: 0; bottom: 0; left: 0; right: 0;
  6. border: 1px dashed #fc0;
  7. }
  8. .A {
  9. -webkit-flex: 0 1 auto;
  10. width: 100%;
  11. border: 1px solid red;
  12. }
  13. .B {
  14. width: 100%;
  15. -webkit-flex: 1 0 auto;
  16. border: 1px solid blue;
  17. }

我还尝试将表包装在块容器内无济于事.

有没有办法用我目前的表来完成这个?或者我是否需要使用其他结构?

最佳答案
我设法通过将表包装到具有flex:1属性的div包装器中来实现.然后我设置高度:100%表.在这种情况下,需要tbody标签.

风格:

  1. .container {
  2. display: flex;
  3. flex-direction: column;
  4. position: absolute;
  5. top: 0; bottom: 0; left: 0; right: 0;
  6. border: 1px dashed #fc0;
  7. }
  8. .A {
  9. border: 1px solid red;
  10. }
  11. .B-wrapper {
  12. flex: 1;
  13. overflow-y: auto;
  14. border: 1px solid blue;
  15. }
  16. .B {
  17. width: 100%;
  18. height: 100%;
  19. }

这是我的小提琴:http://jsfiddle.net/ischenkodv/E4Qbw/58/

猜你在找的CSS相关文章