排版
用於控制元素空白屬性的公用程式。
使用 whitespace-normal
使文字在元素內正常換行。換行符和空格會被壓縮。
<div class="w-3/4 ...">
<div class="whitespace-normal ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
使用 whitespace-nowrap
防止文字在元素內換行。換行符和空格會被壓縮。
<div class="w-3/4 overflow-x-auto ...">
<div class="whitespace-nowrap ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
使用 whitespace-pre
保留元素內的換行和空格。文字不會換行。
<div class="w-3/4 overflow-x-auto ...">
<div class="whitespace-pre ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
使用 whitespace-pre-line
保留元素內的換行,但不保留空格。文字會正常換行。
<div class="w-3/4 ...">
<div class="whitespace-pre-line ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
使用 whitespace-pre-wrap
保留元素內的換行和空格。文字會正常換行。
<div class="w-3/4 ...">
<div class="whitespace-pre-wrap ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
使用 whitespace-break-spaces
來保留元素內的換行符和空格。行尾的空白不會懸掛,而是會換到下一行。
<div class="w-3/4 ...">
<div class="whitespace-break-spaces ...">Hey everyone!
It's almost 2022 and we still don't know if there is aliens living among us, or do we? Maybe the person writing this is an alien.
You will never know.</div>
</div>
Tailwind 讓您可以在不同狀態下使用變體修飾符條件式套用公用程式類別。例如,使用 hover:whitespace-pre
來僅在滑鼠移入時套用 whitespace-pre
公用程式。
<div class="whitespace-normal hover:whitespace-pre">
<!-- ... -->
</div>
有關所有可用狀態修飾符的完整清單,請查看 滑鼠移入、焦點和其他狀態 文件。
您也可以使用變體修改器來鎖定媒體查詢,例如回應式斷點、深色模式、偏好減少動畫等。例如,使用 md:whitespace-pre
來僅在中型螢幕尺寸及以上套用 whitespace-pre
工具程式。
<div class="whitespace-normal md:whitespace-pre">
<!-- ... -->
</div>