javascript - 如何制作复合样式

标签 javascript html css stylesheet

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

有什么方法可以用 CSS 做到这一点吗?

或者您是否必须使用 JavaScript

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

最佳答案

您将使用 calc() .

height: calc(100% - 10px);

jsFiddle example

w3.org 8.1. Mathematical Expressions: ‘calc()’

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 - 如何制作复合样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20793893/

相关文章:

css - 我如何移动这个 block ?

javascript - 如何使用Alex Gorbatchev编写的最新版(3.0.83)语法高亮工具?

javascript - JavaScript 的 headless 测试?

javascript - iOS Safari 忽略 javascript 中的溢出隐藏代码

css - 旋转和倾斜变形文本

javascript - svg 的宽度高度没有改变

jquery - super 鱼的多个实例?

java - 如何在Worklight的客户端代码上使用java?

php - Javascript 在每次加载图像时调整大小

html - html列表项和段落之间的视觉差异