我在html中使用css flexbox創建了3個框,但Chrome使用不同大小的框呈現。以不同寬度呈現的行中的Flex項目
將瀏覽器的邊框以使視圖更小。
感謝您的幫助!
Codepen:https://codepen.io/labanino/pen/rGaNLP
body {
font-family: Arial;
font-size: 2rem;
text-transform: uppercase;
}
.flex {
height: 200px;
display: flex;
flex-direction: row;
}
.flex>section {
flex: 1 1 auto;
display: flex;
justify-content: center;
flex-direction: column;
text-align: center;
}
.flex>section:nth-child(1) {
background: brown;
margin-right: 20px;
border: 1px solid #999;
}
.flex>section:nth-child(2) {
background: pink;
margin-right: 20px;
border: 1px solid #999;
}
.flex>section:nth-child(3) {
background: green;
margin-right: 0;
border: 1px solid #999;
}
<div class="flex">
<section>Brown</section>
<section>Pink</section>
<section>Green</section>
</div>
很不錯@Spartacus。感謝您的解釋。 – Labanino