Add dots/ellipsis on div/span element overflow without using jquery

前端 未结 5 1008
萌比男神i
萌比男神i 2021-02-04 06:58

Need to implement functionality similar to what dotdotdot jQuery plugin does but cannot use javascript frameworks (like jquery or ext).

Is there an

5条回答
  •  被撕碎了的回忆
    2021-02-04 07:31

    Why not using the CSS property text-overflow? It works great as long as you define a width in your tag.

    Class in CSS:

    .clipped {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        
    This is a long text

    You can also add the text to the title attribute, so the user can see the whole text when hovering over the element.

提交回复
热议问题