我在div中有几个跨距,我想知道的是我如何让跨度占据父div的100%宽度,但这些跨度的高度应该是自动的。 CSS:
.parent {
position: fixed;
width: 100%;
height: 80px;
top: 0;
left: 0;
display: flex;
justify-content: space-between;
padding: 0px 20px;
box-sizing: border-box;
z-index: 90;
background: #4070da;
color: white;
font-size: 1.5em;
}
.parent span{
width: 100%;
display: block;
align-items: center;
}
HTML:
<div class="parent">
<span>Depart</span>
<span>07</span>
<span>Mar 2018</span>
</div>
答案 0 :(得分:4)
只需使用常规方法执行此操作并放弃弹性框方法:
.parent {
position: fixed;
width: 100%;
height: 80px;
top: 0;
left: 0;
padding: 0px 20px;
box-sizing: border-box;
z-index: 90;
background: #4070da;
color: white;
font-size: 1.2em;
}
.parent span {
width: 100%;
display: block;
text-align: center;
}
<div class="parent">
<span>Depart</span>
<span>07</span>
<span>Mar 2018</span>
</div>