常见文字样式
行高:line-height,当我i们将行高的大小设置成当前元素的高度时,可以实现当行文本在当前元素中垂直方向居中显示的效果
水平对齐方式:text-align:left|center|right,分别表示设置文字在当前盒子当中水平的对其(左对齐、居中对齐、右对齐)
文字大小:font-size,单位时px,一般情况下浏览器都会有一个最小的显示字体
字体的粗细:font-weight,可以设置关键字,或者数值(100~900),关键字有normal表示正常,还有bold表示加粗
字体名称:font-family,一般常用的就是“微软黒雅”、“黑体”
字体颜色:color,设置文字的颜色,可以使用英语单词,也可以使用十六进制
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>常见的文字样式</title> <style type="text/css"> div{ /*要求设置div里面的文字,在div当中垂直方向居中显示,div的高度为200px*/ height: 200px; width: 200px; line-height: 200px; background: orange; } </style> </head> <body> <div> 胜利就在前方 </div> </body> </html>