主要文件:如何從另一個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