With the-webkit-private attribute, the code is as follows:
Text-overflow:-o-ellipsis-lastline;
Overflow:hidden;
Text-overflow:ellipsis;
Display:-webkit-box;
-webkit-line-clamp:2;-
webkit-box-orient:vertical;
There are other ways to solve this problem:
1, through JS to control the word count, and then intercept the text
Here is an example:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> examples </title>
<style type= "Text/css" >
. demo{width:100px;}
</style>
<body>
<div class= "Demo" id= "Demo" > How to display two lines or three lines of text, then the extra part of the ellipsis instead of?</div>
<script>
JS can not directly through the class to get objects, you must write a method, so that the efficiency is very low, the original JS best with the ID to get the Domo object directly with the ID
var Obox=document.getelementbyid (' demo ');
The slice () method returns the selected element from an existing array.
You can use negative values to select elements from the end of an array.
If end is not specified, then the slice () method selects all elements from start to the end of the array.
Here, you need to modify the value of slice () to achieve what you want to display.
var demohtml = OBox.innerHTML.slice (0,10) + ' ... ';
Fill to specified position
obox.innerhtml = demohtml;
</script>
</body>
2, there is a method is through the background control, with program control, the output of the process is controlled; this will not ...
The text in the div displays two lines, and the extra text is displayed with an ellipsis