div中的自动换行?

问题描述 投票:0回答:1

我试图在div中包装文本。有办法吗?

这是有问题的代码:

<div width="700"><pre><p> " . $texts . "</p></pre></div>

任何线索?

html text word-wrap
1个回答
1
投票

http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/

“长行是由使用pre html标签引起的.pre标签在一大块文本中保留空格和换行符。非常适合显示代码片段。但是,某些代码行很长并且会在页面上运行这就是为什么我的侧边栏被推到IE浏览器页面底部的原因。“

修理:

pre {
  white-space: pre-wrap;       /* css-3 */
  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
  white-space: -pre-wrap;      /* Opera 4-6 */
  white-space: -o-pre-wrap;    /* Opera 7 */
  word-wrap: break-word;       /* Internet Explorer 5.5+ */
}
© www.soinside.com 2019 - 2024. All rights reserved.