简体   繁体   中英

JavaFX - css adding background image with transparency

I want to add an image (png) this way:

#leftCorner {
  -fx-background-image: url("images/backgroundTrain2.png");
  -fx-background-repeat: stretch;
  -fx-background-size: 150.0 71.0;
  -fx-background-position: center center;
}

the problem is that I loose the transparency of the white part of the image. Can somebody tell me what I can do that it stays transparent?

在此输入图像描述

thats the picture i try to add as background

I use -fx-background-color:transparent to set pngs on my Buttons and transparency works. Try this.

-fx-opacity: 0.5;

Add this to your ID in fx css file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM