实现:css
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
效果:webpack
实现:web
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
效果:gulp
注意:app
在使用webpack或gulp压缩css时,如使用autoprefixer打包时,会将 -webkit-box-orient: vertical; 除去,致使多行文本溢出省略号无效。网上的解决办法是在样式先后添加注释,修改的代码以下:spa
overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; /*! autoprefixer: off */ -webkit-box-orient: vertical; /* autoprefixer: on */
发现效果实现了,可是编译后,会出现一条警告: “Second Autoprefixer control comment was ignored. Autoprefixer applies control comment to whole block, not to next rules.“code
对我这个强迫症实在不能接受,查了资料后,再作修改,终于能够。blog
overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; /*! autoprefixer: ignore next */ -webkit-box-orient: vertical;