在React项目中使用 -webkit-line-clamp
和 -webkit-box-orient
属性时,可能会遇到不生效的问题。这通常是因为在编译或打包过程中,这些非标准属性被自动过滤掉了。下面写法是其中一种解决方案,注释必须包含 !
符号,例如 /*! autoprefixer: off */
和 /*! autoprefixer: on */,
来告诉Autoprefixer不要过滤掉 -webkit-box-orient
属性。
.text_6 {
margin-top: 2.9688vw;
width: 22.3438vw;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
/* autoprefixer: off */
-webkit-box-orient: vertical;
/* autoprefixer: on */
-webkit-line-clamp: 4;
}