JavaFX CSS样式的TextArea不工作 [英] JavaFX CSS styling of TextArea does not work
问题描述
我在写一个简单的JavaFX应用程序,但我不能得到一些CSS样式工作。
问题是 TextArea
的 -fx-background-color
属性。
这是相关的CSS:
.text-area {
-fx-font-family:Consolas;
-fx-highlight-fill:#00ff00;
-fx-highlight-text-fill:#000000;
-fx-text-fill:#00ff00;
-fx-background-color:#000000;
}
所有字段按预期运行,除了 -fx -background-colour
,这显然什么也不做。我仍然有默认的白色背景。如下图所示,下面的 TextField
具有相同的CSS,但会按预期应用背景颜色。
我的问题的图片
pre>
.text-area .content {
-fx-background-color:black;
}
...
或者,也可以参阅这个答案: JavaFX 8中textarea的透明背景
I'm writing a simple JavaFX application, but I can't get some of the CSS styling to work.
The problem is the -fx-background-color
property for my TextArea
.
This is the relevant CSS:
.text-area {
-fx-font-family: Consolas;
-fx-highlight-fill: #00ff00;
-fx-highlight-text-fill: #000000;
-fx-text-fill: #00ff00;
-fx-background-color: #000000;
}
All the fields perform as expected, except -fx-background-color
, which apparently does nothing. I still have the default white background. As you can see in the picture, the TextField
below, which has identical CSS, but does apply the background color as expected.
Any clues?
You need to set the content:
.text-area .content{
-fx-background-color: black;
}
...
Or see this answer maybe: Transparent background of a textarea in JavaFX 8
这篇关于JavaFX CSS样式的TextArea不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!