请注意我只需要在Chrome中使用我正在使用的嵌入式设备。另外请不要给任何浮动,表格,内联块等基础解决方案 - 我只对CSS flex答案感兴趣。
那就是说,我的标记如下:
<div class="wrap">
<div class="a">red</div>
<div class="b">blue</div>
<div class="c">green</div>
</div>
CSS as:
.wrap { display: -webkit-flex; height: 100%; }
.a { -webkit-flex: 1; max-width: 100px; background: red; }
.b { -webkit-flex-flow: row; -webkit-flex-direction: row; -webkit-flex: 1; background: blue; }
.c { -webkit-flex-flow: row; -webkit-flex-direction: row; -webkit-flex: 1; background: green; }
我想要实现的布局是:
______________
|red |blue |
| |_______|
| |green |
| | |
|____|_______|
红色框的高度应为100%,最大宽度为100px;蓝色和绿色盒子的高度应该达到100%。谁能告诉我如何使用-webkit-flex实现这一目标?你可以看到我尝试使用弹性流和弯曲方向无济于事。
我创建了一个包含代码的JSBin链接:http://jsbin.com/usisic/3/edit
由于
答案 0 :(得分:2)
.wrap { display: -webkit-flex; max-width: 200px; height:200px; -webkit-flex-flow: column wrap;}
.a .b .c {
max-width: 100px;
-webkit-flex: 1;
}
.a {
height:200px;
background: red;
}
.b {
background: blue;
height:50%;
}
.c {
background: green;
height:50%;
}
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>nested flex</title>
</head>
<body>
<div class="wrap">
<div class="a">red</div>
<div class="nested">
<div class="b">blue</div>
<div class="c">green</div>
</div>
</div>
</body>
</html>
.wrap { display: -webkit-flex; height: 50px; -webkit-flex-direction: row; -webkit-flex-flow: row; -webkit-flex-wrap: wrap;}
.a { -webkit-flex:1; max-width: 100px;background: red;}
.b { background: blue; height:40%; padding-bottom:5px;}
.c { background: green; height:40%; padding-bottom:5px;}
.nested {-webkit-flex:1; max-width: 50px;}
答案 2 :(得分:0)
我无法按预期获得其他答案。 此解决方案不需要设置高度 - 响应可变数量的内容。
html, body {height: 100%; }
.wrap {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 100%;
}
.a {
height: 100%;
max-width: 100px;
}
.b, .c {
width: 100%;
flex-grow: 1;
}
.a { background: red; }
.b { background: blue; }
.c { background: green; }
<div class="wrap">
<div class='a'>red</div>
<div class='b'>blue</div>
<div class='c'>green</div>
</div>