- normal
- pre
- nowrap
- pre-wrap
- pre-line
舉例如下
div {
width: 250px;
height: 80px;
border: thin solid black;
}
.examplenormal {
white-space: normal;
}
.examplepre {
white-space: pre;
}
.examplenowrap {
white-space: nowrap;
}
.exampleprewrap {
white-space: pre-wrap;
}
.examplepreline {
white-space: pre-line;
}
/* 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:text19.css
功能:示範 CSS 2.1 樣式表的使用
作者:張凱慶
時間:西元 2011 年 7 月 */我們以下面的 HTML 文件載入
<html>
<head>
<title>網頁標題</title>
<link rel="stylesheet" type="text/css"
href="text19.css">
</head>
<body>
<div class="examplenormal">
You ever have that feeling where
you're not sure if you're awake or
still dreaming?
</div>
<div class="examplepre">
You ever have that feeling where
you're not sure if you're awake or
still dreaming?
</div>
<div class="examplenowrap">
You ever have that feeling where
you're not sure if you're awake or
still dreaming?
</div>
<div class="exampleprewrap">
You ever have that feeling where
you're not sure if you're awake or
still dreaming?
</div>
<div class="examplepreline">
You ever have that feeling where
you're not sure if you're awake or
still dreaming?
</div>
</body>
</html>
<!-- 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:text19.html
功能:示範 CSS 2.1 樣式表的使用
作者:張凱慶
時間:西元 2011 年 7 月 -->瀏覽器 (broswer) 開啟如下

如結果顯示, normal 為預設的空白字元處理方式, pre 保留原有編排方式,即使內容溢出區塊元件的邊緣, nowrap 會消除所有空白字元,但是不會自動換行, pre-wrap 為自動換行的保有原始編排方式, pre-line 會消除多餘的空格,但保留換行字元。
| 中英文術語對照 | |
|---|---|
| 性質 | property |
| 關鍵字 | keyword |
| 瀏覽器 | broswer |
您可以繼續參考
文字相關
- 字型顏色 color
- 字型種類 font-family
- 字型粗細 font-weight
- 字型尺寸 font-size
- 字型格式 font-style
- 字型變體 font-variant
- 字型伸縮 font-stretch
- 字型大小 font-size-adjust
- 字型 font
- 文字縮排 text-indent
- 水平對齊 text-align
- 文字行高 line-height
- 垂直對齊 vertical-align
- 單字間距 word-spacing
- 字元間距 letter-spacing
- 大小寫轉換 text-transform
- 文字裝飾 text-decoration
- 文字陰影 text-shadow
- 空白字元 white-space
- 文字方向 direction
相關目錄
CSS 2.1 快速導覽
HTML, CSS 教材
首頁
參考資料
http://www.w3.org/TR/CSS21/text.html
https://developer.mozilla.org/en/CSS/white-space
沒有留言:
張貼留言