when text exceeds width, continue in new line

前端 未结 5 1478
暗喜
暗喜 2020-12-18 22:47

I have the following structure:

  • Text goes here

5条回答
  •  攒了一身酷
    2020-12-18 23:37

    Your example already word-wraps (because

    is already a block element), if you want to break words, then you could try:

    p.letters {
        word-wrap: break-word;
    }
    

    Here's a basic working example: http://jsfiddle.net/G9z5M/ (see updates below).

    You can play around with it using various techniques:

    /* Wraps normally, on whitespace */
    p.words {
        word-wrap: normal;
    }    
    
    /* Hides non-wrapped letters */
    p.hidden {
        overflow: hidden;
    }
    
    /* Outputs a single line, doesn't wrap at all */
    p.nowrap {
        white-space: nowrap;
    }​
    

    See updated fiddle: http://jsfiddle.net/G9z5M/1/

提交回复
热议问题