主要文件:如何从另一个CSS规则借用风格
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;
}
到避免重复代码。
这个问题是在这里回答:http://stackoverflow.com/questions/147500/is-it-possible-to-include-one-css-file-into-another – Lemurr 2013-03-15 01:35:09
“我不能这样吗?”听起来有点不对劲。 – hjpotter92 2013-03-15 01:36:46