Insert ellipsis (…) into HTML tag if content too wide

后端 未结 24 3079
名媛妹妹
名媛妹妹 2020-11-22 10:07

I have a webpage with an elastic layout that changes its width if the browser window is resized.

In this layout there are headlines (h2) that will have

24条回答
  •  暖寄归人
    2020-11-22 11:06

    DO THE ELLIPSIS USING ONLY CSS

    
    
    
    
    
    
    This content is more than 200px and see how the the ellipsis comes at the end when the content width exceeds the div width.

    *This code works on most current browsers. If you experience any problem with Opera and IE (which probably you won't), add these in the style:

    -o-text-overflow: ellipsis;  
    -ms-text-overflow: ellipsis;
    

    * This feature is part of CSS3. Its complete syntax is:

    text-overflow: clip|ellipsis|string;
    

提交回复
热议问题