thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.08k stars 168 forks source link

Shadow DOM styling not applied on first load #218

Closed TarheelGrad1998 closed 2 years ago

TarheelGrad1998 commented 2 years ago

My Home Assistant version: 2022.8.3

My lovelace configuration method (GUI or yaml): yaml

What I am doing: I have small markdown cards I use for displaying weather info. I've styled it using card_mod to be smaller (reducing margins on p and h1 tags), which worked a few HA versions ago. Now it does not work on initial load, but will if you click to another dashboard tab and back (but this means my kiosks are never properly styled).

What I expected to happen: Styling to be applied on load

What happened instead: Style only applied when switching tabs

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error
              - content: |
                  <ha-icon icon="mdi:sofa"></ha-icon>
                  # {{ states("sensor.living_room_temperature") }}&deg; 
                card_mod:
                  style:
                    .: |
                      ha-card {
                        height: 65px !important;
                        text-align: center;
                        }
                    ha-markdown:
                      $:
                        ha-markdown-element: |
                          p {
                            margin-bottom: 0px;
                          }
                          h1 {
                            margin-top: 0px;
                          }
                type: markdown
# End of code

Error messages from the browser console:


By putting an X in the boxes ([]) below, I indicate that I:

ildar170975 commented 2 years ago

Check for advices here: https://github.com/thomasloven/lovelace-card-mod/issues/204 https://github.com/thomasloven/lovelace-card-mod/issues/208

TarheelGrad1998 commented 2 years ago

Thanks, the below fixed it. Works perfect now.

               ha-markdown $: | 
                  p {
                    margin-bottom: 0px;
                  }
                  h1 {
                    margin-top: 0px;
                  }