Thanks for your effort. The problem with the margins were not the problem. I did it more ore less 1:1 before. The problem was āonlyā the sticking when using mod-card to get rid of the first margin. And as this is present here as well and I donāt want to switch to an custom-layout card (did it with horizontal (with assigned comlumn, etc.) already before, but I donāt like, that it is not loading in a streaming way card by card but load everything first and show clack/background until it then appears.
card-mod-view-yaml: |
hui-masonry-view $ div#columns div.column hui-vertical-stack-card $: |
#root hui-conditional-card:nth-child(2) {
{% if (states("binary_sensor.ui_alert") == "off") %}
margin-top: 0px;
{% endif %}
}
This one was the clue ā¦ if you only have one dashboard. Later I saw, that if you go to another dashboard and back, etc. this mod getās lost and will not be re-apllied. For whatever reason. So, no real solution, but interesting to know.
And then I though. Why not having a vartical stack as the build in, but with an ha-card (really a pitty, that so many helper-cards in HA are build different than all other cards). Like vertical-stack-in-card or stack-in-card. But tweek it that way, that it looks like tthe build in card, that means re-assign the backgrounds, etc.
This is possible with both cards, bat faster (and with less custom modding) with stack-in-card, because of the keep-objekt. Et voila:
type: custom:stack-in-card
card_mod:
style:
hui-vertical-stack-card$: |
div#root { background-color: red; }
keep:
background: true
margin: true
outer_padding: false
border_radius: true
box_shadow: true
cards:
No sticking. Behavior like in standard card. Order of cards same. Most probably only until I will see or find another problem with this approach, but it looks promising. And with that I can mod the margins as I want.
BTW Ma assumption, why they stick together is, that the mod-card is calculated by HA as 0px height and therefor more or less not existent for the masonry positioning of the cards. So calculation of the break to the next column will start with the next card. Something like that I think.