我想用css规则调整JavaFx中HTMLEditor的行高,但找不到规则的名称。
我尝试了-fx-line-height
和其他一些,但没有一个有效。它甚至可能,还是HTMLEditor太受限制了?
答案 0 :(得分:3)
HTML编辑器编辑HTML,您需要指定line-height in HTML based CSS(而不是JavaFX CSS)。
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
public class SpacedOut extends Application {
private static final String HTML_TEXT =
"<p style=\"line-height:1.5\">\n" +
" <span style=\"font-size:12pt\">The quick brown fox jumps over the lazy dog.</span><br />\n" +
" <span style=\"font-size:24pt\">The quick brown fox jumps over the lazy dog.</span>\n" +
"</p>";
@Override
public void start(Stage stage) throws Exception{
HTMLEditor editor = new HTMLEditor();
editor.setHtmlText(HTML_TEXT);
Scene scene = new Scene(new Pane(editor));
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}