lovelace-card-mod: position: sticky doesn't work

My Home Assistant version: 2024.6.3

With one of the latest Home Assistant updates, the position: sticky property stopped working in some cases.

It works if you use it on a card that is in a grid.

type: grid
square: false
columns: 1
cards:
  - type: custom:stack-in-card
    mode: horizontal
    card_mod:
      style:
        .: |
          :host {
            position: sticky !important;
            z-index: 3 !important;
            top: -20px !important;
          }
          ha-card {
            transition: none !important;
            border-radius: 0px;
            background: var(--primary-background-color);
            box-shadow: 0px 0px 6px 0px  var(--primary-background-color) !important;
            height: 80px;
            margin: -8px -12px;
            padding: 8px 12px;
          }
    cards:
      - type: custom:mushroom-title-card
        title: Комнаты
        title_tap_action:
          action: navigate
          navigation_path: rooms
        card_mod:
          style:
            .: |
              ha-card {
                transition: none !important;
                --primary-text-color: rgb(var(--rgb-grey));  
                --title-font-size: 16px;
                --card-secondary-color: rgb(var(--rgb-grey)); 
                --subtitle-font-size: 14px;
                margin: 7px 0px -18px 0px;
              }
      - type: custom:mushroom-title-card
        subtitle: 4 из 9
        title_tap_action:
          action: navigate
          navigation_path: rooms
        card_mod:
          style:
            .: |
              ha-card {
                transition: none !important;
                --primary-text-color: rgb(var(--rgb-grey));  
                --title-font-size: 16px;
                --card-secondary-color: rgb(var(--rgb-grey)); 
                --subtitle-font-size: 14px;
                text-align: end;
                margin: 8px 0px -4px 0px;
              }
  - type: grid
    square: false
    columns: 2
    cards:
      - type: custom:stack-in-card
        card_mod:
          style: |
            ha-card {
              transition: none !important;
              
              height: 176px !important;
            }
        cards:
          - type: custom:layout-card
            layout_type: custom:grid-layout
            layout:
              grid-template-columns: auto auto
              margin: '-4px -4px 0px -4px;'
            cards:
              - type: custom:mushroom-template-card
                entity: input_text.gostinaia
                tap_action:
                  action: more-info
                icon: hue:room-living
                primary: Гостиная
                layout: horizontal
                badge_icon: null
                card_mod:
                  style:
                    mushroom-state-info$: |
                      .primary {
                        transition: none !important;
                        
                        font-size: 14px !important;
                        position: relative;
                        overflow: visible !important;
                        
                        top: -50px;
                        left: -132px;
                      }
                      .secondary {
                        transition: none !important;
                        
                        position: relative;
                        overflow: visible !important;
                        
                        top: -62px;
                        left: -180px;
                      }
                    mushroom-shape-icon$: |
                      .shape {
                        transition: none !important;
                        
                        position: relative;
                        
                        left: -30px;
                        top: 75px;
                        
                        --icon-color: rgb(253, 64, 112) !important;
                        --shape-color: rgba(254, 64, 112, 0.2) !important;
                        
                        #--icon-symbol-size: 90px;
                      }
                    .: |
                      ha-card {
                        transition: none !important;
                        
                        background: none;
                        box-shadow: none;
                        --badge-icon-size: 1em;
                        --badge-size: 1.5em;
                        width: 100px !important;
                      }
                      :host {
                        --mush-icon-size: 120px;
                      }
              - type: custom:stack-in-card
                card_mod:
                  style:
                    .: |
                      ha-card {
                        transition: none !important;
                        
                        box-shadow: none;
                      }
                cards:
                  - type: custom:mushroom-light-card
                    entity: light.lights_gostinaia
                    icon: mdi:lightbulb
                    primary_info: none
                    secondary_info: none
                    card_mod:
                      style:
                        .: |
                          ha-card {
                            transition: none !important;
                            
                            padding-bottom: 0px !important;
                            --icon-border-radius: 12px;
                            align-items: flex-end;
                          }
                  - type: custom:mushroom-media-player-card
                    entity: media_player.gostinaia_tv
                    icon: mdi:motion-play-outline
                    primary_info: none
                    secondary_info: none
                    tap_action:
                      action: toggle
                    card_mod:
                      style: |
                        ha-card {
                          transition: none !important;
                          
                          padding-bottom: 0px !important;
                          --icon-border-radius: 12px;
                          align-items: flex-end;

                          --rgb-state-media-player: 0, 188, 212;
                        }
                  - type: custom:mushroom-template-card
                    primary: []
                    icon_color: []
                    icon: []
                    secondary: []
                    card_mod:
                      style: |
                        ha-card {
                          transition: none !important;
                          
                          padding-bottom: 0px !important;
                          --icon-border-radius: 12px;
                          align-items: flex-end;
                        }

But it doesn’t work for stack-in-card, which is located in the main dashboard space

type: custom:stack-in-card
mode: vertical
card_mod:
  style:
    .: |
      :host {
        position: sticky !important;
        z-index: 3 !important;
        bottom: -20px !important;
      }
      ha-card {
        transition: none !important;
        box-shadow: 0px 0px 12px 0px var(--primary-background-color) !important;
        background: var(--primary-background-color);
        padding: 0px 0px 0px 0px;
        margin: 0px -8px 0px;
        border-radius: 0px;
        height: 126px;
      }
cards:
  - type: custom:mushroom-chips-card
    card_mod:
      style: |
        ha-card {
          transition: none !important;
          margin: 10px -10px -16px 1px !important;
          box-shadow: inset 0px 0px 12px 10px var(--primary-background-color) !important;
        }
        ha-card > .chip-container {
          flex-wrap: nowrap;
          overflow-x: auto;
          
          overscroll-behavior-x: contain;
          scroll-snap-type: x mandatory;
          scroll-snap-align: start;
        }

        ha-card > .chip-container > * {
          flex-shrink: 0;
        }
    chips:
      - type: template
        card_mod:
          style: |
            ha-card {
              transition: none !important;
              background: none  !important;
              min-width: 0px !important;
              width: 5px !important;
            }
      - type: template
        entity: weather.gismeteo
        content: |-
          {{ states('sensor.current_weather') }}
          {{ states('sensor.gismeteo_apparent_temperature') | round(0) }} °C
        icon: |-
          {% if is_state('weather.gismeteo', 'sunny') %}
          mdi:weather-sunny
          {% elif is_state('weather.gismeteo', 'partlycloudy') %}
          mdi:weather-partly-cloudy
          {% elif is_state('weather.gismeteo', 'cloudy') %}
          mdi:weather-cloudy
          {% elif is_state('weather.gismeteo', 'rainy') %}
          mdi:weather-rainy
          {% elif is_state('weather.gismeteo', 'partly-rainy') %}
          mdi:weather-partly-rainy
          {% elif is_state('weather.gismeteo', 'pouring') %}
          mdi:weather-pouring
          {% elif is_state('weather.gismeteo', 'fog') %}
          mdi:weather-fog
          {% elif is_state('weather.gismeteo', 'hail') %}
          mdi:weather-hail
          {% elif is_state('weather.gismeteo', 'hazy') %}
          mdi:weather-hazy
          {% elif is_state('weather.gismeteo', 'lightning') %}
          mdi:weather-lightning
          {% elif is_state('weather.gismeteo', 'lightning-rainy') %}
          mdi:weather-lightning-rainy
          {% elif is_state('weather.gismeteo', 'partly-lightning') %}
          mdi:weather-partly-lightning
          {% elif is_state('weather.gismeteo', 'snowy') %}
          mdi:weather-snowy
          {% elif is_state('weather.gismeteo', 'snowy-heavy') %}
          mdi:weather-snowy-heavy
          {% elif is_state('weather.gismeteo', 'snowy-rainy') %}
          mdi:weather-snowy-rainy
          {% elif is_state('weather.gismeteo', 'partly-snowy') %}
          mdi:weather-partly-snowy
          {% elif is_state('weather.gismeteo', 'partly-snowy-rainy') %}
          mdi:weather-partly-snowy-rainy
          {% elif is_state('weather.gismeteo', 'clear-night') %}
          mdi:weather-night
          {% elif is_state('weather.gismeteo', 'night-partly-cloudy') %}
          mdi:weather-night-partly-cloudy
          {% endif %}
        icon_color: >-
          {% if is_state('weather.gismeteo', 'sunny') %} #FFF900 {% elif
          is_state('weather.gismeteo', 'partlycloudy') %} #B3B6B7 {% elif
          is_state('weather.gismeteo', 'cloudy') %} #626567 {% elif
          is_state('weather.gismeteo', 'rainy') %} blue {% elif
          is_state('weather.gismeteo', 'partly-rainy') %} #4E4DD8 {% elif
          is_state('weather.gismeteo', 'pouring') %} #2E9AFE {% elif
          is_state('weather.gismeteo', 'fog') %} #C0C0C0 {% elif
          is_state('weather.gismeteo', 'hail') %} white {% elif
          is_state('weather.gismeteo', 'hazy') %} grey {% elif
          is_state('weather.gismeteo', 'lightning') %} #D9D401 {% elif
          is_state('weather.gismeteo', 'lightning-rainy') %} #D9D401 {% elif
          is_state('weather.gismeteo', 'partly-lightning') %} #D9D401 {% elif
          is_state('weather.gismeteo', 'snowy') %} grey {% elif
          is_state('weather.gismeteo', 'snowy-heavy') %} f5f5f5 {% elif
          is_state('weather.gismeteo', 'snowy-rainy') %} f5f5f5 {% elif
          is_state('weather.gismeteo', 'partly-snowy') %} f5f5f5 {% elif
          is_state('weather.gismeteo', 'partly-snowy-rainy') %} f5f5f5 {% elif
          is_state('weather.gismeteo', 'clear-night') %} #FFF900 {% elif
          is_state('weather.gismeteo', 'night-partly-cloudy') %} #B3B6B7 {%
          endif %}
        card_mod:
          style: |
            ha-card {
              transition: none !important;
              
              margin: 2px;
              margin-bottom: 10px;
              padding: 1px 6px 1px 2px;
            }
            .content {
              white-space: pre-wrap;
            }

About this issue

Most upvoted comments

@AINER did you find anything in the meantime? I am really baffled that no one has an answer to this and on the HA forums and discord they don’t even react to this question at all. As in, it is completely ignored.