I'd like to calculate the number of rows in a grid template using calc() , but trying to get the repeat count with division isn't working:
Best Answer-推荐答案 strong>
When using division with calc the result will be a number and not an integer thus it won't work because the repeat() expect an interger
The generic form of the repeat() syntax is, approximately,
repeat( [ <positive-integer> | auto-fill | auto-fit ] , <track-list> ) ref
And
At / , check that the right side is <number> . If the left side is <integer> , resolve to <number> . Otherwise, resolve to the type of the left side.ref
And
Number values are denoted by <number> , and represent real numbers, possibly with a fractional component.ref
Even if we both know that the result will be an integer the browser will still consider it as a number.
You can have the same issue with multiplication in case you have a number in one of the sides
|