我正在尝试学习Flexbox,但是在实现想要的效果时遇到了困难。
我想要的效果:
一个盒子,里面有两个标签(一个数字在标签上方)
第二个盒子里有四个标签(左上角一个,右上角一个,中间一个和底部中间一个)
.flex-container {
display: flex;
background-color: lightgrey;
flex-direction: row;
align-items: stretch;
align-content: stretch;
}
.flex-item {
display: flex;
background-color: cornflowerblue;
margin: 10pt;
}
.flex-item-2 {
display: flex;
background-color: cornflowerblue;
margin: 10pt;
flex: 2 0 0;
}
.flex-qty-container {
font-size: 27pt;
margin: 0;
}
.flex-sub-container {
display: flex;
background-color: yellow;
flex-direction: column;
flex-wrap: wrap;
align-items: flex-start;
flex: 2 0 0;
}
.flex-item-left-corner {
background-color: red;
}
.flex-item-right-corner {
background-color: red;
align-self: flex-end;
font-size: 10pt;
}
.flex-item-center {
background-color: red;
font-size: 12pt;
}
.flex-item-bottom-middle {
background-color: red;
}
<div class="flex-container">
<div class="flex-item">
<div class="">
<p class="flex-qty-container">7</p>
<p class="flex-qty-label">Label</p>
</div>
</div>
<div class="flex-item-2">
<div class="flex-sub-container">
<p class="flex-item-left-corner">top left corner</p>
<p class="flex-item-right-corner">top right corner</p>
<p class="flex-item-center">Center of box</p>
<p class="flex-item-bottom-middle">Bottom middle</p>
</div>
</div>
</div>
display: flex
或inline-flex
)。 - Michael Benjamin