1
爲什麼不彈性項目A當它設置爲margin: 0 auto
時,取整個容器的寬度?Flex項目寬度flex-direction:列和邊距:0 auto
.container {
display: flex;
flex-direction: column;
}
.a {
margin: 0 auto;
border: 1px solid red;
}
.b {
border: 1px solid blue;
}
<div class="container">
<div class="a">A</div>
<div class="b">B</div>
</div>