CSS 文本格式介绍

导读 CSS 文本属性可定义文本的外观。
通过文本属性,您可以改变文本的颜色、字符间距,对齐文本,装饰文本,对文本进行缩进,等等。

CSS 文本格式介绍

文本格式

This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties.
The paragraph is indented, aligned, and the space between characters is specified. The underline is removed from the
“尝试一下” link.

文本颜色

颜色属性被用来设置文字的颜色。

颜色是通过CSS最经常的指定:

十六进制值 – 如: #FF0000
一个RGB值 – 如: RGB(255,0,0)
颜色的名称 – 如: red

一个网页的背景颜色是指在主体内的选择:
实例

body {color:red;}
h1 {color:#00ff00;}
h2 {color:rgb(255,0,0);}

尝试一下 »
对于W3C标准的CSS:如果你定义了颜色属性,你还必须定义背景色属性。

文本的对齐方式

文本排列属性是用来设置文本的水平对齐方式。

文本可居中或对齐到左或右,两端对齐.

当text-align设置为”justify”,每一行被展开为宽度相等,左,右外边距是对齐(如杂志和报纸)。

实例

h1 {text-align:center;}
p.date {text-align:right;}
p.main {text-align:justify;}

尝试一下 »

文本修饰

text-decoration 属性用来设置或删除文本的装饰。

从设计的角度看 text-decoration属性主要是用来删除链接的下划线:

实例

a {text-decoration:none;}

尝试一下 »
也可以这样装饰文字:

实例

h1 {text-decoration:overline;}
h2 {text-decoration:line-through;}
h3 {text-decoration:underline;}

尝试一下 »
我们不建议强调指出不是链接的文本,因为这常常混淆用户。

文本转换

文本转换属性是用来指定在一个文本中的大写和小写字母。

可用于所有字句变成大写或小写字母,或每个单词的首字母大写。

实例

p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}

尝试一下 »

文本缩进

文本缩进属性是用来指定文本的第一行的缩进。

实例

p {text-indent:50px;}

尝试一下 »

原文来自:https://www.runoob.com/css/css-text.html

本文地址:https://www.linuxprobe.com/introduction-to-css-2.html编辑:吴康宁,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

© 版权声明
THE END
喜欢就支持一下吧
赞赏