1. 自身
通过box-sizing:设定边距和边框
不设宽高:利用盒子内外边距、文字高度和大小撑开
【注】<a>
要设block才能撑开
2. 相邻
子取消间距,给父font-size:0
1. 溢出省略号
【1】单行
给自身加width:px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis
【2】多行
控制行数:新增盒子display:webkit-box、上下排列webkit-box-orient:vertical、控制文本行数webkit-line-clamp
宽高尺寸:width:px;height;line-height;font-size;font-weight
设置隐藏:overflow:hidden;text-overflow: ellipsis
;英文字符截断word-break:break-all
2. 把文字顶走,用图片替换(方便搜索引擎检索)
写法一:text-indent:-9999;overflow:hidden
写法二:height:0;margin-top/padding-top:父高;overflow:hidden
写法一:直接用<del>
标签,但显示效果不佳
写法二:盒子span转inline-block
,设字体尺寸和<hr>
,设置hr样式为中心点origin;缩放scale;border:0;width:200%;height:1px
原文:https://www.cnblogs.com/MaricoCheung/p/13666079.html