I currently have this climate button card that I took from André’s code:
Unfortunately the CSS is a bit off, probably due to differences in the theme code. How would I go about to make it look like this (ignore the background color).
This is the code for the button card template:
weather_forecast:
variables:
temp_min: ''
temp_max: ''
aspect_ratio: 1/1
show_icon: false
show_entity_picture: true
show_name: true
show_state: false
show_label: true
tap_action:
action: more-info
styles:
grid:
- grid-template-areas: |
"n"
"temp"
"i"
"s"
"l"
- grid-template-columns: 1fr
- grid-template-rows: min-content repeat(2, 1fr) repeat(2, min-content)
- gap: 0%
card:
- color: > #rgba(157, 160, 162, 1) #rgba(84, 85, 85, 1) #rgba(85, 86, 86, 1)
[[[
if (states['sun.sun'].state == 'below_horizon'){
return 'rgba(157, 160, 162, 1)';
} else
return 'rgba(71, 71, 71, 1)';
]]]
- background: > # else linear-gradient(to top, rgba(123,168,197,0.8) 0%, rgba(61,132,176,0.8) 100%)
[[[
if (states['sun.sun'].state == 'below_horizon'){
return 'linear-gradient(to top, rgba(53,59,83,0.8) 0%, rgba(10,14,34,0.8) 100%)';
} else
return 'linear-gradient(to top, rgb(123 168 197) 0%, rgba(61,132,176,0.8) 100%)';
]]]
# return 'linear-gradient(to top, rgb(123 168 197) 0%, #b0c5d3 100%)'; --- rgb(213, 215, 216)
name:
- place-self: start
- text-transform: uppercase
- font-weight: 400
img_cell:
- justify-content: start
icon:
- width: 37%
label:
- place-self: start
- margin-left: -5px
custom_fields:
temp:
- place-self: start
#- margin-top: -10px
label: >
[[[
return `
<ha-icon icon="mdi:arrow-up-thin" style="width: 1.1em; height: 1.1em; margin-right: -0.3em;"></ha-icon>
<span> ${states[variables.temp_max].state}°</span>
<ha-icon icon="mdi:arrow-down-thin" style="width: 1.1em; height: 1.1em; margin-right: -0.3em;"></ha-icon>
<span> ${states[variables.temp_min].state}°</span>
`
]]]
custom_fields:
temp: >
[[[ return entity.attributes.temperature + "°"; ]]]
entity_picture: |
[[[
if ((entity.state == 'sunny') && (states['sun.sun'].state == 'above_horizon'))
return "/local/svg/weather/clear-day.svg";
if ((entity.state == 'sunny') || (entity.state == 'clear-night') && (states['sun.sun'].state == 'below_horizon'))
return "/local/svg/weather/clear-night.svg";
if (entity.state == 'fog')
return "/local/svg/weather/fog.svg";
if ((entity.state == 'partlycloudy') && (states['sun.sun'].state == 'above_horizon'))
return "/local/svg/weather/partly-cloudy-day.svg";
if ((entity.state == 'partlycloudy') && (states['sun.sun'].state == 'below_horizon'))
return "/local/svg/weather/partly-cloudy-night.svg";
if (entity.state == 'rainy')
return "/local/svg/weather/rain.svg";
if (entity.state == 'sleet')
return "/local/svg/weather/sleet.svg";
if (entity.state == 'snow')
return "/local/svg/weather/snow.svg";
if (entity.state == 'cloudy')
return "/local/svg/weather/cloudy.svg";
else (entity.state == 'wind')
return "/local/svg/weather/wind.svg";
]]]
extra_styles: |
[[[
return `
#name {
font-size: 0.7vw;
}
#temp {
font-size: 1.7vw;
}
#state {
font-size: 0.8vw;
}
#label {
font-size: 0.7vw;
}
/* portrait */
@media screen and (max-width: 2000px) {
#name {
font-size: 0.7vw !important;
}
#temp {
font-size: 1.8vw !important;
}
#state {
font-size: 0.7vw !important;
}
#label {
font-size: 0.7vw !important;
}
}
/* phone */
@media screen and (max-width: 800px) {
#name {
font-size: 2vw !important;
}
#temp {
font-size: 4.5vw !important;
}
#state {
font-size: 2vw !important;
}
#label {
font-size: 2vw !important;
}
}
@keyframes card_bounce {
0% {
transform: scale(1);
}
15% {
transform: scale(0.9);
}
25% {
transform: scale(1);
}
30% {
transform: scale(0.98);
}
100% {
transform: scale(1);
}
}
`
]]]