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 @   by1314  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
浏览器标题切换
浏览器标题切换end
点击右上角即可分享
微信分享提示