css overflow - only 1 line of text

后端 未结 8 1662
别跟我提以往
别跟我提以往 2021-01-30 04:59

I have div with the following css style:

width:335px; float:left; overflow:hidden; padding-left:5px;

When I insert, into that

8条回答
  •  广开言路
    2021-01-30 05:22

    You can use this css code:

    text-overflow: ellipsis; 
    overflow: hidden; 
    white-space: nowrap;
    

    The text-overflow property in CSS deals with situations where text is clipped when it overflows the element's box. It can be clipped (i.e. cut off, hidden), display an ellipsis ('…', Unicode Range Value U+2026).

    Note that text-overflow only occurs when the container's overflow property has the value hidden, scroll or auto and white-space: nowrap;.

    Text overflow can only happen on block or inline-block level elements, because the element needs to have a width in order to be overflow-ed. The overflow happens in the direction as determined by the direction property or related attributes.

提交回复
热议问题