我发现很多几年前的答案(比如 this )都说“不”。然而,事情变了吗?例如,现在是否可能出现这样的情况:
#property1 {
height: 100px
}
#property2 {
height: calc(#property1.height + 50px)
}
我知道我可以用 jquery 做到这一点,但是否可以只用 css 做到这一点?
最佳答案
不,这在简单的 css 中是不可能的,但你可以在 LESS 中做这样的事情:
@size: 100px;
#property1 {
height: @size;
}
#property2 {
height: @size + 50px;
}
了解更多 here .
关于css - 可以从另一个 css 规则引用 css 属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26033673/