下面的代码显示<parent>
容器,其中包含一些<child>
项目。灵活高度和宽度的Flexbox儿童:100%
的<child>
项目被定位在<parent>
项内部与.flex
属性(见屏幕显示:挠曲在父)所以它们恰好填满的父元素。迄今为止,这一切都很好。
不过,现在我要实现的是,display: flex
财产仅适用于<child>
项目的高度所以他们完全适合父元素垂直。
对于宽度我希望每个<child>
项中的100%周边母体的所以最终它们被显示为块(下面彼此而不是彼此相邻)。
为了达到这个目的,我需要更改哪些代码?
您也可以找到我的代码here
html {
height: 100%;
}
body {
height: 100%;
}
.parent {
height: 80%;
width: 100%;
float: left;
display: flex;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: blue;
}
.parent div {
justify-content: space-around;
flex: 1;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: green;
}
<div class="parent">
<div> 1.0 Menu </div>
<div> 2.0 Menu </div>
<div> 3.0 Menu </div>
<div> 4.0 Menu </div>
</div>
完美。正是我在找什么。我也在这里编辑https://jsfiddle.net/onmotyvo/5/ – Michi