So I'm trying to make a responsive resizing post component in angular and tried to change the size for different screen sizes e.g. making the post look bigger on 4k.
My attempt for this would be native css variables (first tried to use sass variables but then learned that because its just a preprocessor it wont be dynamic which totally makes sense).
I have multiple Media queries for different screen sizes and I have a "resize variable" which changes on different queries.
With one query everything to work just fine but once I have a second query that changes the variable it doesnt seem to work anymore?
I cant find anything explaining this and really want to understand this so can someone explain this to me?
The Code (simplified) :
.post{
--header-height: 100px;
--size-factor: 1;
.posthead{
height: calc(var(--header-height) * var(--size-factor);
.{
img{
max-height: calc(var(--header-height) * var(--size-factor);
max-width: calc(var(--header-height) * var(--size-factor);
}
}
}
// 4K
@media only screen and (min-width: 4092px){
.post{
--size-factor: 2.5;
}
}
// 2K
@media only screen and (min-width: 2560px){
.post{
--size-factor: 1.5;
}
}
When I only have the query for 4k and inspect in 4k mode everything looks fine and resizes. But once I have the 2k query both wont work.
note :
The values are just for testing. Obviously I wasnt able to find a sweet number yet.