

Therefore, the next best thing is to use the number of characters as the criterion for text being too long. But there is no interface in the applet that gives JS access to the number of lines of text or the height of the component, so we have no way of telling the logical layer that the number of lines is too high. On the browser side, the container height and the line height of the text can be obtained by DOM to calculate the number of lines displayed in the text. The most direct criterion for judging text length is when the number of lines of text exceeds a certain value. Without this interaction, you can completely ignore the problem. The so-called text is too long text occupies too much height, the reason to judge this is to inform the logic layer to control the display and switch of the "full text" button. How do styles collapse when text is too long.Criteria for determining whether text is too long.Text that is not long is displayed normallyĮssentially, two problems need to be solved to achieve this effect:.


When the user clicks "full text", the folded text will be expanded and the button will be toggled to "Fold up".Make the text too long to collapse and display a "full" click on the text.Javascript The front end webkit Wechat appletsīefore doing small program development, encountered to achieve the effect of folding too long text (type wechat circle of friends that kind).
