如何在我的calc()
中使用CSS(3)中以前定义的样式?我想知道如何,因为我可以使用类似width: calc(80% - calc(padding / 2))
的内容,但我不确定如何直接在CSS中获取padding
。
#main {
padding: 10px;
/* This is how we might do it - remember, we want our width to be 100% - 20px. */
/* See this.padding? */
width: calc(80% - calc(this.padding * 2));
/* Of course, it could be something like self.padding: */
width: calc(80% - calc(self.padding * 2));
/* Or even just (and best of all): */
width: calc(80% + calc(padding * 2));
}
/* What would be even more awesome is if we could get properties from other styles: */
#demo1 {
font-family: Monaco;
}
#demo2 {
font-family: #demo1;
}
/* Of course, we can do this if #demo2 is inside of #demo1: */
#demo1 {
font-family: Monaco;
}
#demo2 {
font-family: inherit;
}
/* But we want to do this without having it use inherit. */
知道怎么做这些吗?我不想使用SASS或var
,因为它仅在Firefox中受支持。