【问题标题】:word-wrap:break-word not working as expected in IE8word-wrap:break-word 在 IE8 中没有按预期工作
【发布时间】:2011-08-10 08:46:29
【问题描述】:

我关注了this

表示要使用 word-wrap:break-word ,我们需要为 table 元素设置“table-layout:fixed”。即使这样,它也不能在 IE8 中工作。我在这里缺少任何基础知识吗?

我在 IE8 和 IE6 中附加了它的屏幕截图。以及如何在 IE8 中呈现 HTML。 (IE8中包含表格的面板有滚动条。)

从呈现的 HTML 中,我发现表格布局是固定的,并且样式也被应用了。

但即便如此 IE8 以不同的方式显示网格。

<table cellspacing="0" rules="all" border="0" id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView" style="border-width:0px;border-style:None;height:150px;width:750px;border-collapse:collapse;**table-layout: fixed**">
            <tr class="Row" align="center">
                <td align="left" style="width:155px;white-space:nowrap;">
                                        <span id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView_ctl02_typeLabel">IT</span>
                                    </td><td align="left" style="width:155px;white-space:nowrap;">
                                        <span id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView_ctl02_firstNameLabel">AAA</span>
                                    </td><td align="left" style="width:155px;white-space:nowrap;">
                                        <span id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView_ctl02_lastNameLabel">BBB</span>
                                    </td><td align="left" style="width:155px;white-space:nowrap;">
                                        <span id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView_ctl02_appReceivedDateLabel">3/01/2011</span>
                                    </td><td align="left" style="width:155px;white-space:nowrap;**WORD-BREAK:BREAK-ALL**">
                                        <span id="ctl00_memberContentPlaceHolder_empiMemberHcidGridView_ctl02_commentsLabel">TestingTestingTestingTestingTestingTestingTestingTestingTestingTestingTestingTesting</span>
                                    </td>
        </table>

任何帮助?提前致谢

【问题讨论】:

    标签: javascript asp.net internet-explorer browser internet-explorer-8


    【解决方案1】:

    实际上,我不会担心您的示例中看到的这种人为文本的自动换行(没有空格)。

    也就是说,解决方案之一可能是将内容包装在 div 中,并将宽度和自动换行应用于 div。例如看这个小提琴:http://jsfiddle.net/6Cm3U/1/

    【讨论】:

    • @Vinay..Thanks..我从开发人员工具栏中看到样式“word-wrap:break-word”应用于 而不是 是导致问题的原因吗?在你说的链接中,样式被应用于 div 并且样式被应用
    • @Ananth, span 是内联元素,因此您还需要将其设为 blockinline-block 才能使分词起作用。查看更新的示例jsfiddle.net/6Cm3U/2 我假设您正在使用生成跨度的 ASP.NET 标签,因此将一些 css 类应用于标签以启用工作中断。
    猜你喜欢
    相关资源
    最近更新 更多
    热门标签