【发布时间】:2013-03-03 15:01:21
【问题描述】:
主要文件:
home.html(访问:只读)
...
<h1>Heading 1</h1>
...
externalFile.css(访问:只读)
.tagh1 {
margin: 10px 0;
font-family: inherit;
font-weight: bold;
}
myfile.css(访问:读/写)
h1 {
color: #08C;
}
如何在 h1 CSS 规则 (myfile.css) 中包含 .tagh1 (externalFile.css) 的样式,而无需将它们从一个文件复制粘贴到另一个文件?
逻辑答案:
h1 {
color: #08C;
/* Just copy and paste them */
margin: 10px 0;
font-family: inherit;
font-weight: bold;
}
但我不能这样做:)
编辑:
我认为可能是这样的:
.tag1 {
property1: value1;
property2: value2;
}
.tag2 {
include(.tag1); /* or something */
property3: value3;
}
为了避免重复代码。
【问题讨论】:
-
问题在这里得到了回答:stackoverflow.com/questions/147500/…
-
“我不能这样吗?”听起来有点不对劲。