我的小提琴至今:3欄的Flex佈局 - 中間一欄只寬度,因爲它的內容
.fill-height-or-more {
min-height: 100%;
display: flex;
}
.fill-height-or-more > div {
-webkit-box-flex: 1;
-webkit-flex: 1;
-moz-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: flex;
justify-content: center;
flex-direction: column;
align-items : center;
}
.some-area > div {
padding: 1rem;
}
.some-area > div:nth-child(1) {
background: #88cc66;
}
.some-area > div:nth-child(2) {
background: #79b5d2;
}
.some-area > div:nth-child(3) {
background: #8cbfd9;
}
.some-area > div h1, .some-area > div h2 {
margin: 0 0 0.2rem 0;
}
.some-area > div p {
margin: 0;
}
html, body {
height: 100%;
}
<section class="some-area fill-height-or-more">
<div>
<h1>LEFT</h1>
</div>
<div>
<h2>Two</h2>
<p>This Column should</p>
<p>only be as width as</p>
<p>its content.</p>
</div>
<div>
<h2>RIGHT</h2>
</div>
</section>
這個職位是一個續集我previous post。
任務1:我希望中間列的寬度與其內容一樣寬。然後左邊和右邊的列應該平等地填充其餘的空間,以便中間的列始終停留在中間。
在此先感謝您的小時幫助!
Muff
此版本的中間內容/文本重疊。中間欄應該始終與內容一樣寬,左右欄應該同化。 – Raggamuffin
你認爲文本重疊是什麼意思?中間欄中的文本應該保持在一行嗎? –
是的文本應該保留在一行,但列寬不適應。 – Raggamuffin