2

我试图在要包装的 XUL 应用程序中获取描述,即使它包含长行。

例如,如果我将以下内容保存为 .xul 文件并在 Firefox 中打开它,它看起来很好并且可以适当地换行:

<?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <window
    id="theWindow"
    title="The Window"
    style="overflow: auto;"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:html="http://www.w3.org/1999/xhtml"
    >


  <vbox flex="1" style="max-width: 200px; overflow:auto; border: 1px dotted black; padding: 2px;">
    <description style="border: 1px solid black; padding: 2px;">test</description>
    <description style="border: 1px solid black; padding: 2px;">test test test test test test test test test test test test test test test test test test test test test</description>
  </vbox>
</window>

但是,如果我删除大行中的空格,它不会被包裹,我只是得到一个滚动条来查看该行:

<?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <window
    id="theWindow"
    title="The Window"
    style="overflow: auto;"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:html="http://www.w3.org/1999/xhtml"
    >


  <vbox flex="1" style="max-width: 200px; overflow:auto; border: 1px dotted black; padding: 2px;">
    <description style="border: 1px solid black; padding: 2px;">test</description>
    <description style="border: 1px solid black; padding: 2px;">testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest</description>
  </vbox>
</window>

当长线达到 200 像素限制时,有什么方法可以使用 CSS 或其他任何方法强制换行?

4

2 回答 2

2

Firefox 3.1 支持这个:http ://www.css3.info/preview/word-wrap/

word-wrap 属性是由 Microsoft 发明并添加到 CSS3 中的。它允许长单词能够被打破并换行到下一行。它有两个值;正常或断词。目前在 IE、Safari 和 Firefox 3.1 (Alpha) 中支持此功能。

对于旧(和当前)版本的 Firefox,没有标准的方法(谷歌是我的朋友)。有些人建议使用<br />在单词中间添加的小脚本。使用word-wrap:break-word并希望用户最终升级。

于 2009-01-12T18:16:38.187 回答
0

最初 ChatZilla 用于将空的 <img> 元素分散到输出中,这些元素将作为长单词可以换行的点,尽管后来改为 <wbr> 元素。

于 2009-10-09T19:56:39.873 回答