我想达到以下布局:Flexbox内的Flexbox - 有可能吗?
+---------+---------------------+
|legend | |
+---------+ |
|csv_input| map |
| | |
| | |
| | |
+---------+---------------------+
+---------+-------+
|legend | |
+---------+ map |
|csv_input| |
| | |
+---------+-------+
https://jsfiddle.net/zwjm16p3/1/
有了这个HTML和CSS:
*,
*:before,
*:after {
box-sizing: border-box;
}
html,
body,
div#wrapper,
div#map {
height: 100%;
}
body {
padding: 0;
margin: 0;
display: flex;
min-height: 100vh;
flex-direction: column;
}
#wrapper {
display: flex;
flex: 1;
background: #fef;
}
#map {
flex: 1;
background: #ffe;
}
#sidebar {
order: -1;
flex: 0 0 20em;
height: 100%;
background: #eff;
}
#sidebar_wrapper {
height: 100%;
width: 100%;
background: #eef;
display: flex;
min-height: 100vh;
flex-direction: row;
}
#legend {
width: 100%;
background: #efe;
flex: 2em 0 0 0;
}
#csv_input {
width: 100%;
background: #eef;
flex: 1;
}
<div id="wrapper">
<div id="map"></div>
<div id="sidebar">
<div id="sidebar_wrapper">
<div id="legend">
Paste CSV data below.
</div>
<textarea id="csv_input"></textarea>
</div>
</div>
</div>
我看到的是:
+----+----+---------------------+
|lege|csv_| |
| | | |
| | | map |
| | | |
| | | |
| | | |
+----+----+---------------------+
我有两个问题:
- 为什么
flex-direction: row;
被忽略? - 我需要
#sidebar_wrapper
股利,或者div可以是一个flexbox中的孩子和另一个flexbox中的孩子吗?
您可能需要设置' flex-direction:column;'到'#sidebar_wrapper'以获得所需的布局。小提琴:https://jsfiddle.net/zwjm16p3/2/ –