【问题标题】:How to make image fill entire button JavaFX如何使图像填充整个按钮JavaFX
【发布时间】:2019-04-02 20:03:37
【问题描述】:

我想让图像适合整个按钮而没有多余的空间。我已经尝试过了,但它不起作用:

 .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");
}

这是我得到的结果:

如何让退出图片(红色方块)填满整个按钮?

【问题讨论】:

  • 试试background-size:100% 100%

标签: java css image javafx imageview


【解决方案1】:

需要设置背景尺寸,否则背景尺寸设置为零。请尝试以下操作:

.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;

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-04
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 2014-06-07
    • 2013-05-31
    • 1970-01-01
    相关资源
    最近更新 更多