我想创建一个button在按下时改变其风格的东西.这是我的CSS代码:
button {
font-size: 18px;
border: 2px solid gray;
border-radius: 100px;
width: 100px;
height: 100px;
}
button:active {
font-size: 18px;
border: 2px solid red;
border-radius: 100px;
width: 100px;
height: 100px;
}Run Code Online (Sandbox Code Playgroud)
<button>Button</button>Run Code Online (Sandbox Code Playgroud)
仅当我点击并按住它时才会更改.我想在按下之后改变它的样式.例如,正常状态为白色,点击状态为绿色,点击释放后为红色.
当用户在我的JavaFX2.2用户界面中按下按钮时,会出现一个深蓝色光环,表示它已被点击.在活动过程中,我的程序可能想要"取消"它以显示它已不再被选中.
我原以为button.setSelected(false);我记得Swing曾经有过这个,但是在JavaFx中没有这样的调用.该文章讨论了阴影,但我想简单地用一个按钮被点击时使用的相同的外观,这是不是一个真正的阴影.setEffect(new DropShadow())
使用setStyle()还可以,但要使用什么值?
我正在使用以下 css 来自定义我的滚动条
/* The main scrollbar **track** CSS class */
.workspace-grid .scroll-bar:horizontal .track,
.workspace-grid .scroll-bar:vertical .track{
-fx-background-color:transparent;
-fx-border-color:transparent;
-fx-background-radius: 0em;
-fx-border-radius:2em;
}
/* The increment and decrement button CSS class of scrollbar */
.workspace-grid .scroll-bar:horizontal .increment-button ,
.workspace-grid .scroll-bar:horizontal .decrement-button {
-fx-background-color:transparent;
-fx-background-radius: 0em;
-fx-padding:0 0 10 0;
}
/* The increment and decrement button CSS class of scrollbar */
.workspace-grid .scroll-bar:vertical .increment-button ,
.workspace-grid .scroll-bar:vertical .decrement-button {
-fx-background-color:transparent;
-fx-background-radius: 0em;
-fx-padding:0 10 0 0;
}
.workspace-grid .scroll-bar .increment-arrow, …Run Code Online (Sandbox Code Playgroud)