CSS 2.1 快速導覽 - 文字縮排 text-indent

text-indent 性質 (property) 為 CSS 中用來設定區塊元素 (block element) 中文字的縮排 (indent) ,可用數字或百分比。



舉例如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.example1 {
    text-indent: 10;
}
 
.example2 {
    text-indent: 20;
}
 
.example3 {
    text-indent: 30;
}
 
.example4 {
    text-indent: 40;
}
 
.example5 {
    text-indent: 50;
}
 
.example6 {
    text-indent: 60;
}
 
.example7 {
    text-indent: 70;
}
 
.example8 {
    text-indent: -20;
}
 
.example9 {
    text-indent: 50%;
}
 
/* 《程式語言教學誌》的範例程式
    檔名:text10.css
    功能:示範 CSS 2.1 樣式表的使用
    作者:張凱慶
    時間:西元 2011 年 7 月 */


我們以下面的 HTML 文件載入
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<html>
<head>
<title>網頁標題</title>
<link rel="stylesheet" type="text/css"
      href="text10.css">
</head>
<body>
Free your mind.
<div class="example1">Free your mind.</div>
<div class="example2">Free your mind.</div>
<div class="example3">Free your mind.</div>
<div class="example4">Free your mind.</div>
<div class="example5">Free your mind.</div>
<div class="example6">Free your mind.</div>
<div class="example7">Free your mind.</div>
<div class="example8">Free your mind.</div>
<div class="example9">Free your mind.</div>
</body>
</html>
 
<!-- 《程式語言教學誌》的範例程式
     檔名:text10.html
     功能:示範 CSS 2.1 樣式表的使用
     作者:張凱慶
     時間:西元 2011 年 7 月 -->


瀏覽器 (broswer) 開啟如下



我們可以看到負整數也可以用作縮排的設定值。


中英文術語對照
性質property
區塊元素block element
縮排indent
瀏覽器broswer


您可以繼續參考

JavaScript 範例

文字相關


相關目錄
CSS 2.1 快速導覽
HTML, CSS 教材
首頁


參考資料
http://www.w3.org/TR/CSS21/text.html
https://developer.mozilla.org/en/CSS/text-indent

沒有留言: