wbr tag doesn't work in IE

后端 未结 2 1440
你的背包
你的背包 2021-01-04 01:32

Soft break seems not to work in IE. Is there any alternative or how to make it work?

http://fiddle.jshell.net/88q54/1/

body {
font-size: 272px;    
         


        
相关标签:
2条回答
  • 2021-01-04 01:53

    Add the following into your style sheet:

    wbr:after { content: "\00200B"; }
    

    This inserts U+200B ZERO WIDTH SPACE, which is the character-level counterpart of the good old <wbr> that browsers have largely spoiled (a sad story).

    Alternatively, you can replace <wbr> tags by that character, which you can write in HTML as &#x200b;.

    0 讨论(0)
  • 2021-01-04 02:05

    Jukka's answer is a good one. However, in the case below, it's desireable to allow the user to copy the text, which is an e-mail address. In that scenario, the &#x200b; character can't sneak into the string. It therefore has to be solved differently, using multiple inline elements (e.g. <span> or <i>) with display: inline-block;.

    In this instance, <i> tags surround e-mail address components ending with a . or starting with a @.

    .wbr-i-container i {
      display: inline-block;
      font-style: inherit;
    }
    
    <a class="wbr-i-container"
    ><i>FirstName.</i
    ><i>MiddleName.</i
    ><i>LastName</i
    ><i>@company.</i
    ><i>com</i
    ></a>
    

    <i> is used for brevity & readability, while <span> would be semantically correct.

    Works in current versions of Chrome, Firefox, IE and Safari.

    0 讨论(0)
提交回复
热议问题