text-overflow: ellipsis doesn't appear to be working

前端 未结 2 766
渐次进展
渐次进展 2020-12-29 20:09

I have a nav menu in an unordered list:

  • Home
相关标签:
2条回答
  • 2020-12-29 21:02

    You need to add white-space: nowrap; for text-overflow: ellipsis; to work.

    Demo: http://jsfiddle.net/ThinkingStiff/Dc7UA/

    Output:

    enter image description here

    CSS:

    a { 
        text-decoration: none; 
        text-overflow: ellipsis; 
        display: block; 
        overflow: hidden; 
        white-space: nowrap;
        width: 80px; 
        height: 32px;
    }
    
    0 讨论(0)
  • 2020-12-29 21:02

    Actually overflow:hidden; is required, so you'll probably need those three lines:

    text-overflow: ellipsis; 
    display: block; 
    overflow: hidden; 
    
    0 讨论(0)
提交回复
热议问题