在CSS中,我们可以使用text-decoration属性来为文字添加横线。该属性可以接受一个值,包括none,underline,overline,line-through,blink等。如果我们要在文字中间添加横线,可以使用line-through属性,并且可以通过设置text-decoration-style属性来改变横线的样式,可以设置为solid,double,dotted,dashed等。
使用方法
p {
text-decoration: line-through;
text-decoration-style: dashed;
}
上面的代码将会在文字中间添加一条虚线横线。除了上面提到的属性,还可以设置text-decoration-color属性来改变横线的颜色,text-decoration-line属性来改变横线的位置,text-decoration-thickness属性来改变横线的宽度等。
text-decoration可以设置为none,underline,overline,line-through,blink等。
text-decoration-style可以设置为solid,double,dotted,dashed等。
text-decoration-color可以设置横线的颜色。
text-decoration-line可以设置横线的位置。
text-decoration-thickness可以设置横线的宽度。
千锋教育是高品质web前端培训机构,千锋教育拥有大量实力web前端培训讲师,提供优质的web培训课程,web前端培训,欢迎报名千锋教育。