Hi … the example is simple.
I have one svg image with the house plan … e.g.
The size of this svg is 1000px x 500px. It is transparent with white path to be able to colorize it simply with css.
Then I have several svg icons of the same size and only one element e.g. 1 window, again white to be able to add color to it. These icons are put one over the other. When the window is closed, I colorize the window transparent, so it is invisible, when it is open I colorize it blue.
Then the result is following
It could be done as images, but then it is not possible to colorize it simply with css. Therefore I want to use icons.
Unfortuntely I am not a css expert, so I dont know how to tweak it to stretch the icon to the size of the element card. Using px moving and defining size works with one device size, but using different device or landscape mode the result is incorrect.
Other thing is that it works with rectangular icons (same height and width), which is not my case.
The whole picture is an svg file which is put into UI as icon not image. e.g. fapro: floor_plan and fapro: window_livingroom and using card_mod is colorized.
It could be as well any icon eg. mdi:home.
The main picture is empty = transparent.
All picture elements are icon, all are places one over the other, have the same dimension and their visibility is controled via color - if set to some color = visible, if color is set to transparent = invisible
Or the question could be formulated: How to automatically stretch an icon in pisture elements to the width of underlaying main picture.
Thank you so much IIdar for these explanations. I was going insane trying to position things around and that helped me a LOT.
Here’s couple of things that I’ve noted.
After trying a bunch of different cards sizes, I still had issues with a good 20px being off when resizing the browser. I was able to fix that by:
Changing the value over or under 410px was causing differences between the browser and my phone screen. It felt like the card was to wide but you could only see it when placing elements over it.
Now, the funny thing about that is that if I set the translate to (0,0) and play with the top and left percentage, the card get scaled. Here it is at left: 80%
I have no idea why it’s behaving this way, but if I set the top and left to 0% and only play with the translate it works…
Anyway, I’m happy that I came across this post but I’m wondering if being able to set a fixed width and height in this card without card mod might help? this way you could refer to positions in pixels instead of percentage.
IMHO there are some limitations for resizing SVG; in my tests icon’s width/height could not be bigger than 300px - unless I manually set it bigger than 300px.
Hi, I have a card showing EV charging info. Can I change the background image when the car is charging? I would need to have the change take place when “switch.chalky_charger_switch” (not used in this card) is “on” and switch between a static image and a gif showing the charging animation.
I have already successfully manually changed the background image from a static screenshot image to “/local/charging.gif” and that works fine.
I have read the documentation but could not find a relevant reference to this use case.
right, so I think Ive read this topic 3 times now, did a full text search, but can not find a way how to get my states colored… mind you, this is my first and only picture-elements, so please be gentle…
I see yes, that would be a nice workaround, thanks. Was this discussed before? the card not being able to use the regular action configuration? Seems a bit odd imho and not consistent with all other cards.
btw, I moved the styling of the action_button to the button_card_templates. Figured it might come in handy in other spots as well:
resulting in the following config entry for that element in the picture-elements card:
- type: custom:button-card
template: styles_action_button
name: ga naar sankey-chart
style:
top: 90%
left: 20%
tap_action:
action: navigate
navigation_path: /ui-data/energie_sankey
Ive outlined it horizontally with the icon at the top, might change that because I feel it’s a bit of a visual mess… otoh, the regular position of these action-buttons on eg the Powerflow card is a bit of a distraction too.
Only need to find a way to add a type:divider there now. Might need yet another custom element for that.