Using modulus in css calc function

前端 未结 4 1385
无人及你
无人及你 2020-12-06 16:47

Is there any way to use or implement modulus operator in css calc function?
I know there is mod operator and IE supports it, but what about other browsers?

For

相关标签:
4条回答
  • 2020-12-06 17:05

    Unfortunately, there is no more mention of the mod operator in recent specs.

    The calc() function allows mathematical expressions with addition (+), subtraction (-), multiplication (*), and division (/) to be used as component values.

    You may want to resort to using javascript to achieve such behaviour.

    var el = document.getElementById('element-id');
    el.style.width = (100 % 5) + '%';
    
    0 讨论(0)
  • 2020-12-06 17:05

    Only Internet Explorer supports the mod function, I'm afraid, and it has been dropped from the CSS spec, so other browsers are not likely to support it any time soon.

    0 讨论(0)
  • 2020-12-06 17:20

    This operator is no longer supported in browsers. You can only use standard operations with calc:

    • addition +
    • subtraction -
    • multiplication *
    • division /

    This calc() article provides a further detailed explanation on the function.

    0 讨论(0)
  • 2020-12-06 17:21

    Simply..."NO".

    MDN

    The expression can be any simple expression combining the following operators, using standard operator precedence rules:

    + Addition.

    - Subtraction.

    * Multiplication. At least one of the arguments must be a <number>.

    / Division. The right-hand side must be a <number>.

    0 讨论(0)
提交回复
热议问题