Is it possible to do mathematics inside CSS?

前端 未结 5 1073
孤独总比滥情好
孤独总比滥情好 2020-12-01 01:36

I have jquery accorion id #accordion and some of the content inside header class name .simpleColor. Now I want to give a calculated margin to .simp

5条回答
  •  感动是毒
    2020-12-01 02:09

    You can do maths in CSS e.g.:

    height: calc(100% - 20%);

    CSS will also handle the different units, so this works too:

    height: calc(100% - 20px);

    Additionally, min(), max() and clamp() have also been added allowing for calculations like this:

    height: min(calc(100% - 20px), 50%);

    1. min(): gets the minimum value;
    2. max(): gets the maximum value; and
    3. clamp(): limits a value by providing an upper and lower bound.

提交回复
热议问题