Skip to content

Instantly share code, notes, and snippets.

@ifyour
Forked from anonymous/index.html
Last active August 24, 2017 01:53
Show Gist options
  • Save ifyour/a62a7244eb22b7c7155430b471f44fc8 to your computer and use it in GitHub Desktop.
Save ifyour/a62a7244eb22b7c7155430b471f44fc8 to your computer and use it in GitHub Desktop.
2行文字溢出显示省略, 支持 IE // Demo: http://js.jirengu.com/bozur
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.ellipsis-clamp {
line-height: 20px;
max-height: 40px;
text-overflow: ellipsis;
-webkit-text-overflow: ellipsis;
-moz-text-overflow: ellipsis;
box-orient: vartical;
-webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
line-clamp: 2; /** 显示的行数 **/
-webkit-line-clamp: 2; /** 显示的行数 **/
-moz-line-clamp: 2; /** 显示的行数 **/
display: -webkit-box;
word-break: break-all;
overflow: hidden; /** 隐藏超出的内容 **/
}
</style>
</head>
<body>
<p class="ellipsis-clamp">
测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字测试文字
</p>
<script id="jsbin-source-css" type="text/css">.ellipsis-clamp {
line-height: 20px;
max-height: 40px;
text-overflow: ellipsis;
-webkit-text-overflow: ellipsis;
-moz-text-overflow: ellipsis;
box-orient: vartical;
-webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
line-clamp: 2; /** 显示的行数 **/
-webkit-line-clamp: 2; /** 显示的行数 **/
-moz-line-clamp: 2; /** 显示的行数 **/
display: -webkit-box;
word-break: break-all;
overflow: hidden; /** 隐藏超出的内容 **/
}</script>
</body>
</html>
.ellipsis-clamp {
line-height: 20px;
max-height: 40px;
text-overflow: ellipsis;
-webkit-text-overflow: ellipsis;
-moz-text-overflow: ellipsis;
box-orient: vartical;
-webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
line-clamp: 2; /** 显示的行数 **/
-webkit-line-clamp: 2; /** 显示的行数 **/
-moz-line-clamp: 2; /** 显示的行数 **/
display: -webkit-box;
word-break: break-all;
overflow: hidden; /** 隐藏超出的内容 **/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment