更新時(shí)間:2022-02-17 10:25:13 來源:動(dòng)力節(jié)點(diǎn) 瀏覽1054次
CSS 文本格式屬性用于格式化文本和樣式文本。
1.Text-color
2.Text-alignment
3.Text-decoration
4.Text-transformation
5.Text-indentation
6.Letter間距
7.Line height
8.Text-direction
9.Text-shadow
10.字間距
Text-color 屬性用于設(shè)置文本的顏色。
文本顏色可以通過名稱“red”、十六進(jìn)制值“#ff0000”或RGB值“rgb(255, 0, 0)來設(shè)置。
句法:
身體
{
顏色:顏色名稱;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
color:red;
}
h2
{
color:green;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
TEXT FORMATTING
</h2>
</body>
</html>
文本對齊屬性用于設(shè)置文本的水平對齊方式。
文本可以設(shè)置為左對齊、右對齊、居中對齊和兩端對齊。
在對齊對齊中,線條被拉伸以使左右邊距筆直。
句法:
身體
{
文本對齊:對齊類型;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
color:red;
text-align:center;
}
h2
{
color:green;
text-align:left;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
TEXT FORMATTING
</h2>
</body>
</html>
文本裝飾用于在文本中添加或刪除裝飾。
文本裝飾可以是下劃線、上劃線、直通或無。
句法:
身體
{
text-decoration:裝飾類型;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
color:red;
text-decoration:underline;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
TEXT FORMATTING
</h2>
</body>
</html>
文本轉(zhuǎn)換屬性用于改變文本的大小寫,大寫或小寫。
文本轉(zhuǎn)換可以是大寫、小寫或大寫。
大寫用于將每個(gè)單詞的首字母變?yōu)榇髮憽?/p>
句法:
身體
{
文本轉(zhuǎn)換:類型;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
text-transform:lowercase;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
TEXT FORMATTING
</h2>
</body>
</html>
文本縮進(jìn)屬性用于縮進(jìn)段落的第一行。
大小可以是 px、cm、pt。
句法:
身體
{
文本縮進(jìn):大小;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
text-indent:80px;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
This is text formatting properties.<br>
Text indentation property is used to indent the first line of the paragraph.
</h2>
</body>
</html>
該屬性用于指定文本字符之間的空格。
大小可以以 px 為單位。
句法:
身體
{
字母間距:大小;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
letter-spacing:4px;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
This is text formatting properties.
</h2>
</body>
</html>
該屬性用于設(shè)置行間距。
句法:
身體
{
行高:大小;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
line-height:40px;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
This is text formatting properties.<br>
This property is used to set the space between the lines.
</h2>
</body>
</html>
文字方向?qū)傩杂糜谠O(shè)置文字的方向。
可以使用 rtl 設(shè)置方向:從右到左。
從左到右是文本的默認(rèn)方向。
句法:
身體
{
方向:rtl;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
direction: rtl;
text-align:center;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2><bdo dir="rtl">
This is text formatting properties.
</bdo>
</h2>
</body>
</html>
文字陰影屬性用于給文字添加陰影。
您可以指定文本的水平尺寸、垂直尺寸和陰影顏色。
句法:
身體
{
text-shadow:水平尺寸垂直尺寸顏色名稱;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
text-shadow:3px 1px blue;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
This is text formatting properties.
</h2>
</body>
</html>
字間距用于指定行的字之間的間距。
大小可以以 px 為單位。
句法:
身體
{
字間距:大小;
}
例子:
<!DOCTYPE html>
<html>
<head>
<style>
h2
{
word-spacing:15px;
}
</style>
</head>
<body>
<h1>
GEEKS FOR GEEKS
</h1>
<h2>
This is text formatting properties.
</h2>
</body>
</html>
谷歌瀏覽器
IE瀏覽器
火狐
歌劇
蘋果瀏覽器
初級 202925
初級 203221
初級 202629
初級 203743