To answer a general question:
Is there a way to make CSS calc () never a negative value?
The answer is no, because CSS does not provide a way to manually limit (or pinch) the amount to the minimum or maximum value.
Regardless of whether a number or length can be limited to a limited range, it depends on the property that this calc() value has. From spec :
The value obtained from the expression must be clamped to a range that is valid in the target context.
These two equivalents are 'width: 0px', since widths less than 0px are not allowed.
width: calc(5px - 10px); width: 0px;
For example, while negative values ββfor margin and z-index valid, negative values ββfor border-width , padding , height , width , etc. not. Their specificity is almost always determined in the specification for the corresponding property.
As you seem to be using view units in your example, you can use media queries in conjunction with them as demonstrated by fcalderan .
Boltclock
source share