how to avoid text overflow in twitter bootstrap?

后端 未结 4 611
無奈伤痛
無奈伤痛 2021-02-05 01:57

I\'m new to Twitter Bootstrap. I wrote following HTML:

@Html.ActionLink(item.Name
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 02:06

    Of course the question title is broad... it'll depend on Bootstrap's structure you're working with since it may have CSS rules which can interfere with your code.

    In my situation I have a structure with row-fluid, span#s and label CSS classes like this:

    Taking advantage of the code provided by SaurabhLP I used this shorten CSS version which did it for me:

    .standard-description {
        overflow: hidden;
        -ms-text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        text-overflow: ellipsis;
        display: block;
    }
    

    It correctly places an ellipsis in the text inside the span when the title is very long.

    As a plus: if you want to make the text break line, then you can try this CSS instead:

    .standard-description {
    
        white-space:pre-line;
    
    }
    

提交回复
热议问题