61,112
社区成员
发帖
与我相关
我的任务
分享
.ellipsis { /*单行;显示后面的省略号(...)*/
/*width: 100%;*/
height: 1.5em;
line-height: 1.5em; /*以上可能要微调*/
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.ellipsis_multi { /*多行;显示后面的省略号(...)*/
/*width: 100%;*/
height: 3em;
line-height: 1.5em;
-webkit-line-clamp: 2; /*以上可能要微调*/
display: -webkit-box;
word-break: break-all;
word-wrap: break-word;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.ellipsis {
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.ellipsis_2 {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
word-break: break-all;
white-space: normal !important;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width:device-width,initial-scale:1.0,user-scalable=no">
<title>Document</title>
<style type="text/css">
/*单行文本溢出*/
.inaline{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
/*多行文本溢出*/
.inmultiline{
display: -webkit-box !important;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
</style>
</head>
<body>
<div style="width:200px;" class="inaline">This is some long text that will not fit in the box</div>
<br>
<div style="width:300px;" class="inmultiline">
GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside millions of other developers
</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
*{padding:0;margin:0;}
#nn{
text-overflow: ellipsis;
white-space: nowrap;
width: 200px;
overflow: hidden;
}
</style>
<body>
<div id="nn">1234567891011121314151617181920456789101112131415161718192456789101112131415161718192</div>
</body>
</html>