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.php
颜色属性被用来设置文字的颜色。css
颜色是经过CSS最常常的指定:html
十六进制值 - 如"#FF0000"css3
一个RGB值 - "RGB(255,0,0)"api
颜色的名称 - 如"红"spa
参阅 CSS 颜色值 查看完整的颜色值。ssr
一个网页的背景颜色是指在主体内的选择:设计
body {color:blue;} h1 {color:#00ff00;} h2 {color:rgb(255,0,0);}
对于W3C标准的CSS:若是你定义了颜色属性,你还必须定义背景色属性。code
文本排列属性是用来设置文本的水平对齐方式。orm
文本可居中或对齐到左或右,两端对齐.
当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;}
指定字符之间的空间
这个例子演示了如何增长或减小字符之间的空间。
指定行与行之间的空间
这个例子演示了如何指定在一个段落中行之间的空间
设置元素的文本方向
这个例子演示了如何改变元素的文本方向。
增长单词之间的空白空间
这个例子演示了如何增长一个段落中的单词之间的空白空间。
在元素内禁用文字环绕
这个例子演示了如何禁用一个元素内的文字环绕。
垂直对齐图像
这个例子演示了如何设置文本的垂直对齐图像。
添加文本阴影
这个例子演示了如何设置文本阴影。
属性 | 描述 |
color | 设置文本颜色 |
direction | 设置文本方向。 |
letter-spacing | 设置字符间距 |
line-height | 设置行高 |
text-align | 对齐元素中的文本 |
text-decoration | 向文本添加修饰 |
text-indent | 缩进元素中文本的首行 |
text-shadow | 设置文本阴影 |
text-transform | 控制元素中的字母 |
vertical-align | 设置元素的垂直对齐 |
white-space | 设置元素中空白的处理方式 |
word-spacing | 设置字间距 |