记录几个CSS属性定义文本换行,不换行以及超出隐藏显示省略号的方法。
CSS定义文本自动换行
div{ word-wrap:break-word; word-break:normal; }
CSS强制英文单词换行
div{ word-break:break-all; }
CSS强制不换行的方法
div{ white-space:nowrap; }
CSS定义单行文本超出显示省略号的方法
div{ width:200px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
CSS定义多行文本超出显示省略号的方法
div{ display:-webkit-box; overflow:hidden; text-overflow:ellipsis; -webkit-line-clamp:3; -webkit-box-orient:vertical; }
table表格中单元格文本不换行的方法
table{ table-layout:fixed; } table tr td{ width:60%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }