如何使图像填充整个按钮JavaFX
How to make image fill entire button JavaFX
我想制作适合整个按钮的图像,没有多余的 space。我试过这个,但它不起作用:
.toggle-button {
-fx-background-image: url("close.png");
-fx-background-repeat: stretch;
-fx-background-position: center center;
}
.toggle-button:selected{
-fx-background-image: url("contact.png");
}
这是我得到的结果:
如何让退出图片(红色方块)填满整个按钮?
您需要设置背景尺寸,否则背景尺寸设置为零。请尝试以下操作:
.toggle-button {
-fx-min-height: 132px;
-fx-min-width: 128px;
-fx-background-image: url("close.png");
-fx-background-size: 100% 100%;
-fx-background-repeat: no-repeat;
-fx-background-position: center 8px;
}
我想制作适合整个按钮的图像,没有多余的 space。我试过这个,但它不起作用:
.toggle-button {
-fx-background-image: url("close.png");
-fx-background-repeat: stretch;
-fx-background-position: center center;
}
.toggle-button:selected{
-fx-background-image: url("contact.png");
}
这是我得到的结果:
如何让退出图片(红色方块)填满整个按钮?
您需要设置背景尺寸,否则背景尺寸设置为零。请尝试以下操作:
.toggle-button {
-fx-min-height: 132px;
-fx-min-width: 128px;
-fx-background-image: url("close.png");
-fx-background-size: 100% 100%;
-fx-background-repeat: no-repeat;
-fx-background-position: center 8px;
}