Is it possible to do mathematics inside CSS?

前端 未结 5 1067
孤独总比滥情好
孤独总比滥情好 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:15

    It is not possible to do mathematic operations inside CSS natively. You could use JavaScript to change CSS properties on page load, but this is a pain and must be done every page load making your page slow.

    You'll need to use a CSS preprocessor like LESS, Stylus, or SASS.

    The bonus to using either of these languages is that you can generate actual CSS stylesheets from them. You also get benefits like functions, mixins, variable, and more.

提交回复
热议问题