html text exceeds plus ellipsis

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:
dome1

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:
dome2

Scope:
the use of extended attributes WebKit CSS, which method is applicable to WebKit browser and mobile terminal;

Note:

  1. 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:
  2. display: -webkit-box; have binding properties, as the elastically stretchable object model display box.
  3. -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:
dome3
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:

    1. The height is set to an integer multiple of the line-height, preventing the excess characters are exposed.
    2. To p :: after adding a gradient background to avoid text only show half.
    3. 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:
dome1

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:
dome2

Scope:
the use of extended attributes WebKit CSS, which method is applicable to WebKit browser and mobile terminal;

Note:

  1. 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:
  2. display: -webkit-box; have binding properties, as the elastically stretchable object model display box.
  3. -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:
dome3
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:

    1. The height is set to an integer multiple of the line-height, preventing the excess characters are exposed.
    2. To p :: after adding a gradient background to avoid text only show half.
    3. 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.

Guess you like

Origin www.cnblogs.com/xiaozhang666/p/11444767.html