How to break word after special character like Hyphens (-)

后端 未结 11 2023
南方客
南方客 2020-12-04 17:31

Given a relatively simple CSS:

11条回答
  •  一整个雨季
    2020-12-04 18:13

    In all modern browsers* (and in some older browsers, too), the element is the perfect tool for providing the opportunity to break long words at specific points.

    To quote from that link:

    The Word Break Opportunity () HTML element represents a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.

    Here's how it could be used to in the OP's example (or see it in action at JSFiddle):

    12333-2333-233-23339392-332332323

    *I've tested it in IE9, IE10, and the latest versions of Chrome, Firefox, and Opera, and Safari.

    div {
      width: 150px;
    }
    12333-2333-233-23339392-332332323

提交回复
热议问题