Floating DIV in JTextPane

I have an HTML file that I upload to a JTextPane that contains two DIVs that I'm trying to show side by side (using CSS float). However, everything I try does not work. An item is instructionsdisplayed below the item title, always. I also tried adjusting the width. Does JTextPane support this CSS property? Should I use a table? The file displays correctly in 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>
+3
source share
1 answer

HTML support in Swing is mostly at best and only supports HTML3.2. So it is entirely possible that you do not want to do.

DIV, ( CSS float).

HTML, JTextPanes , HTML. , ​​ scrollpane, .

+4

Source: https://habr.com/ru/post/1733671/


All Articles