Write mobile phone page when encountered, more than two lines of text, more text needs to be omitted.
CSS code:
Overflow:hidden;
Text-overflow:ellipsis;
Display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
This is good, because the mobile phone page is not compatible with the FF browser to see the effect of the time, there is a lot of compatibility issues.
Baidu a bit, found useful after the wording, no compatibility problems! Convinced ~
Cross-Browser compatible scenarios
A relatively simple way is to set the relative positioning of the container height, with the inclusion of ellipses (...) Implementation of elemental simulation;
For example:
- P {
- Position:relative;
- Line-height:1.4em;
- / * 3 times the line-height to show 3 lines * /
- Height:4.2em;
- Overflow:hidden;
- }
- P::after {
- Content:"...";
- Font-weight:bold;
- Position:absolute;
- Bottom:0;
- Right:0;
- Padding:0 20px 1px 45px;
- Background:URL(http://css88.b0.upaiyun.com/css88/2014/09/ellipsis_bg.png) repeat-y;
- }
Study the
FF literal ellipsis