1.文本控制的常用属性
属性 | 说明 |
Font-family | 设置字体类别 |
Font-size | 设置字体大小 |
Font-weight | 设置字体粗细 |
Font-style | 设置字体倾斜 |
text-decoration | 设置添加到文本的修饰效果 |
color | 设置文本的颜色 |
text-align | 设置文本的水平对齐方式 |
text-indent | 设置段落的首行缩进 |
line-height | 设置行高 |
word-spacing | 设置字间距 |
letter-spacing | 设置字符间距 |
text-transform | 设施之文本大小写 |
2设置文字样式
2.1设置文字的字体
语法: font-family:字体名称
参数: 字体名称按照优先顺序排列,用逗号隔开。
2.2设置字体大小
语法: font-size:绝对尺寸 | 相对尺寸 | 百分数
参数:
绝对尺寸:根据对象字体进行调节,可选值有 x-small | small | medium | large | x-large
相对尺寸:是相对于父对象中字体尺寸进行相对调节
百分数:其取值是基于父对象中的字体的尺寸
2.3设置字体的粗细
语法: font-weight:bold | number | normal
参数:
bold 为粗体,相当于number值的700
number取值为数字
normal为正常字体,相当于number的400
2.4设置字体的倾斜
语法: font-style:normal | italic | oblique
参数: normal为无效果,italic为斜体,oblique为倾斜体
2.5设置字体修饰
语法: text-decoration:underline | blink | overline | overline | line-through | none
参数:
underline下划线
blink闪烁
overline上划线
line-through贯穿线
none无装饰
2.6设置文本颜色
语法:color:颜色值
参数可为颜色名、颜色十六进制码、rgb代码、rgb百分数