html - css 自动换行 : break-word won't work

标签 html css

我有两个内联跨度。代码示例:

    <div class="comment_content">

        <span class="comment_author"><?= $child_comment['comment_author'] ?></span>
        <span class="comment_text"><?= $child_comment['comment_content'] ?></span>

    </div>

和 scss 示例:

.comment_content {        
    word-wrap: break-word;
}
.comment_author {
    display: inline-block;
    vertical-align:top;
}
.comment_text {            
    display: inline-block;
    word-wrap: break-word;
    width: 100%;
}

如果我的预期 View 必须是:Expected result

如果用户输入不带空格的字符串,字符串不会中断。并打破设计:Problem

如何正确拆分长单词??

最佳答案

white-space: nowrap 将阻止 word-break 生效。一些模板应用 white-space: nowrap,这需要用 white-space: normal 覆盖此属性。

关于html - css 自动换行 : break-word won't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418352/

相关文章:

html - 如何在 td 中显示背景图像,而不是文本?

javascript - Bootstrap Datepicker 未加载

javascript - 获取我的设备的宽度和高度并将它们注入(inject)我的 css 样式

html - Bootstrap 轮播的分辨率和宽高比图像大小

css - CSS 中的背景图像不适用于三星电视 SDK 2011 模型/模拟器

jquery - 可以让动画背景变白并覆盖其他图像

css - 单台 mac osx 机器上的任何浏览器都无法呈现字体

css - margin-bottom 有点跨浏览器的灰色区域

javascript - 如何让JS变量在页面刷新后保留值?

jquery - div的水平和垂直对齐方式