Skip to content

Instantly share code, notes, and snippets.

@teal-front
Last active December 12, 2023 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teal-front/5e19be48034e869e7513c4cc657d5af4 to your computer and use it in GitHub Desktop.
Save teal-front/5e19be48034e869e7513c4cc657d5af4 to your computer and use it in GitHub Desktop.
css snippets
// 动态文本
// 最多展示两行,超出直接截断
// 需要垂直居中,所以把文本单独放一个div里面,设置最大的高度为2行的高度
.image-text {
display: flex;
align-items: center;
justify-content: center;
&--inner {
max-height: rem(44);
line-height: rem(22);
word-break: break-all;
overflow: hidden;
}
}
// 多行文本
%multi-line-ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
// 单行文本
%text-overflow {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
// 动态配置的多行文本,会默认转行的
// 导致可能一个单词占一行
// 设置word-break: break-all强制不占一行,先占上一行再换行
%word-break {
word-break: break-all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment