Hi all:
I’m fighting with some tricky CSS styling issue with card-mod, I’d like apply to a state-icon (in a PE card) so that:
- Animation works on the SVG icon
- The background hides with screen size is below 750px
I can achieve either goal easily but when I put them together, looks like the selector always only take what’s defined first, for example with the code below animation and color work, but media query style doesn’t apply:
- type: state-icon
<<: *toggle_actions
entity: switch.kitchen_aquarium_plug
title: Pump
style:
<<: *icon_style
top: 18%
left: 40%
card_mod:
style:
state-badge:
$:
ha-state-icon:
$:
ha-icon:
$: |
ha-svg-icon {
{% if is_state(config.entity, 'off') %}
color: var(--error-color);
animation: none;
{% else %}
color: var(--running-color);
animation: wave 5s linear infinite;
{% endif %}
}
@keyframes wave {
0% { transform: rotate(0deg); }
20% { transform: rotate(15deg); }
60% { transform: rotate(-15deg); }
100% { transform: rotate(0deg); }
}
$: |
@media (max-width: 750px) {
:host {
/* This targets the outer state-icon element for small screens */
background-color: transparent !important;
backdrop-filter: none !important;
}
}
I’m no expert of CSS and already tried more than 10 ways suggested by ChatGPT without luck.
So would like to confirm here if this is even possible with css?