CSS word-wrap: break-word don't work on IE9

2019-02-21 10:12发布

I have a small css script that force <a> tag word-wrap in a div. It worked fine on FF, Chrome but didn't work on IE9. How can I fix it?

.tab_title a{
    word-wrap: break-word;
} 

9条回答
Ridiculous、
2楼-- · 2019-02-21 10:39

i just figured out that word-wrap:break-word works only partially in IE8 and IE9. If I have a string of words with spaces, then that string gets wrapped. But if my string consists of one long word, it forces the parent/container element to expand according to its width

查看更多
放我归山
3楼-- · 2019-02-21 10:42

I remove the anchor tag after .tab_title class and it works

查看更多
倾城 Initia
4楼-- · 2019-02-21 10:42

I have had good success in Chrome, Firefox and IE with using:

word-break: break-word;
word-wrap: break-word;

In my problem case I was using:

display: table-cell;

and I ended up having to include

max-width: 440px;

to get wrapping in all browsers. In most cases the max-width was not necessary. Using

word-break: break-all;

does not work well in IE because although long words without spaces will be wrapped, short words also stop wrapping at spaces.

查看更多
聊天终结者
5楼-- · 2019-02-21 10:47

I recently was fighting this in Angular between IE/Edge & Chrome. Here is what I found worked for me

  overflow-wrap: break-word;
  word-wrap: break-word;

This gave me the best of both. It would break the word that was too long, but unlike word-break it would not break mid-word.

查看更多
贼婆χ
6楼-- · 2019-02-21 10:48

This might do the trick: http://www.last-child.com/word-wrapping-for-internet-explorer/

Another post also suggests applying word-break:break-all and word-wrap:break-word to it.

查看更多
We Are One
7楼-- · 2019-02-21 10:48

For me it worked in both Chrome and IE with:

.word-hyphen-break {
  word-break: break-word;
  word-wrap: break-word;
  width: 100%;
}

like this no need to configure specific width.

查看更多
登录 后发表回答