javascript-如何制作复合样式

我想输入一些复合样式值,例如:height:100%-10px;

有什么办法用CSS做到这一点?

还是必须使用JavaScript

如果可以,您可以发表您的建议吗?

解决方法:

您将使用calc().

height: calc(100% - 10px);

jsFiddle example

w3.org 07002

The calc() function allows mathematical expressions with addition (‘+’), subtraction (‘-’), multiplication (‘*’), and division (‘/’) to be used as component values. The ‘calc()’ expression represents the result of the mathematical calculation it contains, using standard operator precedence rules. It can be used wherever , , , , , or values are allowed. Components of a ‘calc()’ expression can be literal values, ‘attr()’ or ‘calc()’ expressions, or values that resolve to one of the preceding types.

上一篇:Javascript设置打印样式表


下一篇:javascript-如何获取已加载样式表的内容