CSS calc with inherit

守給你的承諾、 提交于 2019-12-06 16:38:04

问题


I would like to use inherit with calc() like this:

#foo {
  animation-duration: 10s;
}
#foo > .bar {
  animation-duration: calc(inherit + 2s); /* =12s */
}

But it don't seem to works.

Is it browsers bug or specs?


回答1:


The inherit keyword can only exist alone as a value in a property declaration. It cannot be used with anything else as a value, because it's a value in and of itself. This means it cannot be used with functions like calc() either. See CSS2.1 and css3-cascade.

Furthermore, the calc() function itself only takes literal numeric values such as numbers, dimensions and percentages.

So to put it simply, the spec doesn't allow using inherit that way.



来源:https://stackoverflow.com/questions/21605946/css-calc-with-inherit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!