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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)