一. 文本对齐方式
属性名: text-align
取值:
注意点:
- 如果需要让文本水平居中,text-align属性给文本所在标签(文本的父元素)设置
示例:
<style>
/* text-align属性给文本所在标签(文本的父元素)设置 */
h1 {
text-align: center;
}
</style>
二.文本缩进
属性名: text-indent
取值:
- 数字+px
- 数字+em(推荐:1em =当前标签的font-size的大小)
示例:
<style>
p {
/* text-indent属性设置单位为em可随字体大小变化而变化,比较经常使用 */
text-indent: 2em;
font-size: 40;
}
</style>
三.文本修饰
属性名: text-decoration
取值:
示例:
<style>
div{
text-decoration: underline;
}
p{
text-decoration: line-through;
}
h3{
text-decoration: overline;
}
a{
text-decoration: none;
}
</style>
四.行高
作用:控制一行的上下行间距
属性名: line-height
取值:
- 数字+px
- 倍数(当前标签font-size的倍数)
应用
- 1让单行文本垂直居中,可以设置 line-height: 文字父元素高度
- 2.网页精准布局时,会设置 line-height:1 可以取消上下间距行高与font连写的
注意点
- 如果同时设置了行高和font连写,注意覆盖问题
- font : style weight size/line-height family