CSS的文本样式

 

1、颜色

2、文本对齐方式

3、首行缩进

4、行高

5、装饰

1. 文本位置

居中: text-align: center;

靠左: text-align: left;

靠右: text-align: right;

首行缩进:text-indent: 2em; //首行缩进2个字

行高:当行高和块的高度一致时,就可以实现上下居中效果(单行文字上下居中):(两行代码)

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>Title</title>
   <link rel="stylesheet" href="style.css">
</head>
<body>

<p class="p1">
  宋钢:“要是换成你,你会怎么办?”
</p>

<p class="p2">
  李光头:“要是换成我,我就宰了你!”
</p>

<p class="p3">
  宋钢:“我是你的兄弟啊?”
</p>

<p class="p4">
  李光头:“兄弟也一样宰了。”
</p>

<p class="p5">
  出自:余华的小说《兄弟》。
</p>

</body>
</html>

CSS:

/*
类选择器:. 类名字{}
*/
.p1 {
   font-family: 楷体;
}

.p2 {
   font-size: 30px;
}

.p3 {
   font-weight: bold;
}

.p4 {
   color: red;
}

.p5 {
   font: oblique bolder 16px "楷体";
}

效果:

 

 

 

 

 

 

 

 

猜你喜欢

转载自www.cnblogs.com/WZ-BeiHang/p/12347569.html