我试图在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>

有什么方法可以使用CSS或其他任何东西来强制长线在达到200像素限制时被包裹?

有帮助吗?

解决方案

Firefox 3.1支持此功能: http://www.css3.info/preview/word -wrap /

  

自动换行属性由Microsoft发明并添加到CSS3中。它允许长字可以被打破并包裹到下一行。它有两个值;正常或断言。   IE,Safari和Firefox 3.1(Alpha)目前支持此功能。

对于旧的(当前)版本的Firefox,没有标准的方式(谷歌是我的朋友)这样做。有人建议使用一个小脚本,在单词的中间添加<br />。使用自动换行:break-word 并希望用户最终升级。

其他提示

最初ChatZilla用于散布空<!> lt; img <!> gt;输出中的元素将作为长单词可以换行的点,虽然后来改为<!> lt; wbr <!> gt;元件。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top