3

我有一个 HTML 文件,我正在加载到一个 JTextPane 中,其中包含我试图并排显示的两个 DIV(使用 CSS float)。但是,无论我尝试什么,都行不通。instructions元素始终显示在元素下方title。我也尝试过调整宽度。JTextPane 是否不支持此 CSS 属性 - 我必须使用表格吗?该文件在 Safari 中正确显示。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <style type="text/css">
            @font-face {
                font-family: Mentone;
                src: local(Mentone),
                    url(Mentone.otf) format("opentype"),
            }

            div#container { width: 95%; margin: 0px auto; }
            div#title { font-family: Mentone; font-size: 108px; width: 200px; margin: 100px 15px 0 15px; float: left; }
            div#instructions { font-family: Mentone; font-size: 130%; width: 300px; margin: 100px 15px 0 15px; color: #dddddd; }
        </style>
        <title>Welcome</title>
    </head>
    <body>
        <div id="container">
            <div id="title">my app</div>
            <div id="instructions">Instructions go here.</div>
        </div>
    </body>
</html>
4

1 回答 1

4

Swing 中的 HTML 支持充其量只是支持 HTML3.2。因此,很可能不支持您想要做的事情。

其中包含我试图并排显示的两个 DIV(使用 CSS 浮动)。

If you are in control of the HTML, try displaying two separate JTextPanes side by side each containing separate HTML. Both text panes could be added to a panel and the panel added to a scrollpane so they scroll in sync.

于 2010-02-20T16:19:00.953 回答