1. CSS 常用文本属性

文本间距

div.hello1{letter-spacing: 90px;} 字母间距
div.hello1{word-spacing: 90px;} 单词间距(根据空格来识别的)

文本修饰

div.hello1{text-decoration: 线的位置 线的类型 线的颜色}
例子:
上划线:div.hello1{text-decoration: overline;}
下划线:div.hello1{text-decoration: underline;}
中划线:div.hello1{text-decoration: line-through;}
无划线:div.hello1{text-decoration: none;} 超链接的下划线也可以取消
上划虚线:div.hello1{text-decoration: overline dotted green;}

文本缩进

p{text-indent: 120px;}

文本对齐

p{text-align: center;}
值:left、right、center

文本行高

这个元素可以继承
1)像素:p{line-height: 100px;} 像素这种写法,font-size 与 line-height 不要数值一样,一般行高是1.5倍字体大小
2) 数值:p{line-height: 1.5;}
3)百分比:p{line-height: 150%;}
4)normal:p{line-height: normal;} 由浏览器根据文字大小决定一个默认值

height 与 line-height:height是容器的高度,写了height就是这个属性值,没有设置height,默认是line-height*行数
行高作用于:

  • 调整行间距
  • 单行文字的垂直居中,在height=line-height时
  • 让字体放在最下面:line-height=height*2 - font-size - x (也可以用定位去做)

vertical=align

子元素中使用,不能控制块元素,作用于单元格或者同一行元素之间中文字的垂直对齐方式

  • baseline:子元素与父元素基线对齐
  • middle:使元素的中部父元素的基线加上父元素高度一半对齐
  • top
  • bottom
posted @ 2024-03-24 00:28  by1314  阅读(2)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end