5
我試圖設置帶三列的flexbox佈局。左列和右列具有固定的寬度。中間的列有流體寬度來填充可用空間,但是它包含一個長文本,不應該打包並使用省略號。Flexbox - 帶「無包裝」文本的流體柱
不幸的是,未包裹的文本不能提供列的可用空間並將整個佈局推送到父元素的邊界之外。
img {
max-width: 100%;
}
#container {
display: flex;
max-width: 900px;
}
.column.left {
width: 350px;
flex: 0 0 350px;
}
.column.right {
width: 350px;
flex: 0 0 350px;
}
.column.center {
// fluid width required
}
h1 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div id="container">
<div class="column left">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="">
</div>
<div class="column center">
<h1>
This is long text. If overflow use ellipsis
</h1>
</div>
<div class="column right">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="">
</div>
</div>
鏈接撥弄: http://jsfiddle.net/2Lp8d80n/
任何幫助表示讚賞。
如你所說,你可以使用CSS屬性'柔性基礎:350像素;',而不是'柔性:0 0 350像素;在左,右列'。 ':'' – Ricky
@RicardoRuiz,如果你使用'flex-basis'而不是'flex',那麼'flex-shrink'默認爲'1'。但OP希望'flex-shrink:0'。正如規範建議的那樣,爲了覆蓋初始值,最好使用'flex'屬性。請參閱* flex-shrink *因子*:http://stackoverflow.com/a/34355447/3597276 –