-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css] 第38天 实现单行文本居中和多行文本左对齐并超出显示"..." #141
Comments
.one {
text-align: center
}
.multi {
overflow: hidden
text-overflow: ellipsis
display: -webkit-box
-webkit-line-clamp: 3
-webkit-box-orient: vertical
} 可惜多行文本省略, 有严重的兼容性问题 |
是啊,谷歌内核的才支持这个写法 |
@rocky-191 ff68支持了 |
@wenyejie 多行溢出不需要 |
多行文本溢出目前没有解决方案 |
.container {
text-align: center;
height: 100px;
width: 100px;
overflow: hidden;
word-break: break-all;
.content{
text-align: left;
display: inline-block;
}
} ps:实现了单行居中 多行居左 但是没办法并且超出显示... 估计是用伪元素遮住最后几个文字显示... |
愚兄前些年看过篇文章,与众贤弟分享一下。 |
多行显示非Chrome只能使用JS来完成了啊, 写的一个方法 供参考 用法如下:
|
|
.linex(@num) {
display: -webkit-box;
overflow: hidden;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: @num;
} |
|
以上方法仅在高版本google和firefox适用 要想适配所有浏览器和低版本需要和JS一起实现,判断字数是否超过两行,然后只留下两个的字符再减2,再在最好加上...... |
纯css https://codepen.io/hou499/pen/OJNRezZ |
|
第38天 实现单行文本居中和多行文本左对齐并超出显示"..."
The text was updated successfully, but these errors were encountered: