我有兩個文本塊。文本的長度不是固定的(用戶輸入)。左側的塊中有短文本,但右側塊可能包含非常長的文本。塊應該並排顯示,並分散在父母的恆定寬度的100%上,不能少於100%。CSS - 內聯塊100%寬度
簡化的例子: https://jsfiddle.net/hh6a03cy/1/
<div style="white-space: nowrap; font-size: xx-large;">
<span>woohoo</span>
<div style="display: inline-block; overflow-wrap: break-word; width: 100%; white-space: normal; vertical-align: top;">gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</div>
</div>
在此解決方案的問題是,有一個水平滾動條,因爲右塊需要其父寬度的100%,但是由於COMULATIVE寬度應採取以下兩塊應該是100%。
任何想法?
謝謝!
嗚呼!有效!這個單詞有什麼用呢?但是,爲什麼它不能用'換行'(break-word)(只是好奇,因爲這件事讓我浪費了幾個小時)? –
@EllaShar Flexbox扭結,我相信 - 因爲您需要指定一個寬度才能使用「自動換行」。 –
所以官方文檔真的很讓人困惑,我認爲'word break'只是針對CJK(亞洲)語言:( –