Definition from w3c: 正常空格的序列將崩潰爲單個空白。文字將在必要時包裝。這是默認播放» nowrap空格的序列將摺疊成單個空格。文本將永遠不會換行到下一行。文本繼續在同一行,直到遇到
標記。White-space:nowrap vs white-space:normal爲什麼對浮動元素的影響如此之大?
那麼爲什麼它在浮動元素的外觀上有如此多的不同呢?
例如比較這:
JsBin with white-space normal showing a nicely aligned layout
<table>
<thead>
<tr>
<th>
<div style="background-color: lightblue; width: 600px; white-space: normal;">
<span style="display: inline-block; height:20px; background-color: red; margin: 5px 3px;float: left;">
Button
</span>
<span style="display: inline-block; height:20px; background-color: red; margin: 5px 3px;float: none;">
Button
</span>
<span style="display: inline-block; height:20px; background-color: red; margin: 5px 3px; float:right;">
Button right
</span>
<div style="clear: both" />
</div>
</th>
</tr>
</thead>
<tbody>
<tr><td>note: white-space is normal here</td></tr>
</tbody>
</table>
White this where white-space: nowrap is used
這是相同的代碼上面,只是這一次的空白:NOWRAP;
有人有線索? [編輯] 人們評論說,他們看不出有什麼區別,我上傳的問題空白的屏幕截圖:NOWRAP 我在Firefox 10.0.4
爲什麼你要做'白空間:nowrap;'首先呢?它沒有它:[小鏈接](http://jsbin.com/ibifoq/28/edit)。 – Chris
我其實沒有看到任何區別。另外,您沒有任何文字可以放在首位。除非您的文本通常會換行到另一行,否則您不應該看到區別。 – Scrimothy
'white-space:nowrap'對於使用'text-overflow:ellipse'也是至關重要的# – Scrimothy