编程语言
首页 > 编程语言> > javascript-如何制作复合样式

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.

标签:stylesheet,css,html,javascript
来源: https://codeday.me/bug/20191030/1964815.html