兩行或三行(多行)文字溢位顯示...不生效
阿新 • • 發佈:2019-02-09
就在剛剛需要在react專案寫一個限制文字長度兩行,溢位顯示省略號的場景,但是沒有生效,經過查閱,得到以下解決方法,供參考~
初次寫法:
.item-title{
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
}
但是沒有生效~,檢視盒模型
發現-webkit-box-orient:vertical;並未設定成功,據大神網友提供解決方案,優化程式碼如下:
.item-title{
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
/* autoprefixer: off */
-webkit-box-orient:vertical;
/* autoprefixer: on */
-webkit-line-clamp:2;
}
成功設定!