I have a Floorplan as a png picture with some transparent areas on it. Now, I want to set the background color behind the picture. This is what I tried without success. Can someone please tell me the mistake or show me a different approach. Thanks.
The picture elements style is for the element itself. To specifiy a CSS style like you have you would need to use card_mod.
A few alternative solutions to explore.
Use an SVG of the desired colour as a background, and the place your main image as an image element with no interaction. My example below. You will need to play with the image element as far as top/left depening on the apect ratio so may take a little fiddling.
Create a theme with card-background-color set and select that theme for the card. This method does not need tweaking of sizes so is probably easier to use, but requires to setup a basic theme (see Theme Instructions)
Thanks for your answer. I actually wanted to set the background color based on the opacity of a outdoor light sensor. I didn’t mention that. I worked it out so now I use a white base screen with a black overlay. On top of both is my actual floorplan. Still, my problem is that I don’t get the black screens opacity shine based on the lux value of the light sensor. Can you help me here, too?
The stock Home Assistant cards do not support templating. This is a card-mod only feature. Assuming your overlay is the first picture elements, use card-mod and add the following. If your overlay is not the first picture element, change the number in hui-image:nth-child(1).