【问题标题】:Wordwrap within css div [closed]css div中的自动换行[关闭]
【发布时间】:2013-11-09 17:45:12
【问题描述】:

我的 div 容器中的自动换行存在问题。这是此特定代码部分的代码。即使指定的文本行中没有空格,我也希望它自动换行到下一行。

#content {
    position: justify;
    font-size: 10px;
    font-family: Times new roman;
    width: 80%;
    padding: 10px 10px 10px 10px;
    height: auto;
    overflow-x: auto;
    color: #000;
}

【问题讨论】:

  • 定义文本应该如何换行到下一行。在某些允许的断点处(哪个?),使用连字符,还是使用字符串 brok en arbitra rily?人们通常提供的解决方案意味着最后一个选项,这几乎总是错误的,尽管这取决于内容。

标签: css html word-wrap


【解决方案1】:

你需要word-wrap:break-word

jsFiddle example

#content {
    word-wrap: break-word;
    position:justify;
    font-size: 10px;
    font-family: Times new roman;
    width: 80%;
    padding: 10px 10px 10px 10px;
    height: auto;
    overflow-x: auto;
    color: #000;
}

【讨论】:

    【解决方案2】:

    将此添加到您的 CSS 中

    word-wrap: break-word;
    

    【讨论】:

      猜你喜欢
      • 2010-10-04
      • 2013-01-17
      • 2018-10-11
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多