Why does this `word-wrap: break-word` rule not work as expected in Firefox?
当相应的规则在Chrome中有效时,为什么
此处的
当我使用(非标准)WebKit
在Firefox中,除非我专门将
如果您在Firefox上查看此代码段,则会看到
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | .form-field { border: none; padding: 0; max-width: 300px; margin: 0 auto 10px; outline: 1px solid purple; } .form-field legend { text-align: left; width: 100%; word-wrap: break-word; word-break: break-word; } .form-field input[type=text] { width: 100%; font-size: 16px; padding: 7px 14px; box-sizing: border-box; border: 1px solid #c8d7e1; } |
1 2 3 4 | <fieldset class="form-field"> <legend>Betweenthesetwo, InowfeltIhadtochoose. Mytwonatureshadmemoryincommonbutallotherfacultiesweremostunequallysharedbetweenthem.</legend> <input type="text"> </fieldset> |
(在macOS Chrome 64和Firefox 57中测试)。
Firefox不支持
我们需要的是
1 | word-break: break-all; |
更新图例的CSS
1 2 3 4 5 6 | .form-field legend { text-align: left; width: 100%; word-wrap: break-word; word-break: break-all; // Modified } |