If you implement single-line text display overflow ellipsis students should know by text-overflow: ellipsis property, of course, also need to add width to width is a compatible part of the browser.
Implementation:
overflow: hidden;
text-overflow:ellipsis; white-space: nowrap;
The effect is as:
However, this property only supports single-line text display overflow ellipsis, if we are to achieve the multi-line text display overflow ellipsis yet.
Then talk about the focus on multi-line text display overflow ellipsis, as follows.
Implementation:
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
The effect is as:
Scope:
the use of extended attributes WebKit CSS, which method is applicable to WebKit browser and mobile terminal;
Note:
- The number of rows -webkit-line-clamp block for limiting a text element displayed. To achieve this effect, it requires a combination of other properties WebKit. Common combination of attributes:
- display: -webkit-box; have binding properties, as the elastically stretchable object model display box.
- -webkit-box-orient the necessary binding properties, set or retrieve a telescopic arrangement of the object sub-element cassette.
Implementation:
p{position: relative; line-height: 20px; max-height: 40px;overflow: hidden;} p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px; background: -webkit-linear-gradient(left, transparent, #fff 55%); background: -o-linear-gradient(right, transparent, #fff 55%); background: -moz-linear-gradient(right, transparent, #fff 55%); background: linear-gradient(to right, transparent, #fff 55%); }
FIG Effect:
Scope:
The method for a wide range, but the case does not exceed the line of text will appear ellipsis, the optimization method may be combined js.
Note:
- The height is set to an integer multiple of the line-height, preventing the excess characters are exposed.
- To p :: after adding a gradient background to avoid text only show half.
- Since the content is not displayed ie6-7 content, so to add tags compatible ie6-7 (eg: <span> ... <span />); compatible ie8 need to replace :: after: after.
If you implement single-line text display overflow ellipsis students should know by text-overflow: ellipsis property, of course, also need to add width to width is a compatible part of the browser.
Implementation:
overflow: hidden;
text-overflow:ellipsis; white-space: nowrap;
The effect is as:
However, this property only supports single-line text display overflow ellipsis, if we are to achieve the multi-line text display overflow ellipsis yet.
Then talk about the focus on multi-line text display overflow ellipsis, as follows.
Implementation:
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
The effect is as:
Scope:
the use of extended attributes WebKit CSS, which method is applicable to WebKit browser and mobile terminal;
Note:
- The number of rows -webkit-line-clamp block for limiting a text element displayed. To achieve this effect, it requires a combination of other properties WebKit. Common combination of attributes:
- display: -webkit-box; have binding properties, as the elastically stretchable object model display box.
- -webkit-box-orient the necessary binding properties, set or retrieve a telescopic arrangement of the object sub-element cassette.
Implementation:
p{position: relative; line-height: 20px; max-height: 40px;overflow: hidden;} p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px; background: -webkit-linear-gradient(left, transparent, #fff 55%); background: -o-linear-gradient(right, transparent, #fff 55%); background: -moz-linear-gradient(right, transparent, #fff 55%); background: linear-gradient(to right, transparent, #fff 55%); }
FIG Effect:
Scope:
The method for a wide range, but the case does not exceed the line of text will appear ellipsis, the optimization method may be combined js.
Note:
- The height is set to an integer multiple of the line-height, preventing the excess characters are exposed.
- To p :: after adding a gradient background to avoid text only show half.
- Since the content is not displayed ie6-7 content, so to add tags compatible ie6-7 (eg: <span> ... <span />); compatible ie8 need to replace :: after: after.