2015-01-08 19 views
0

例如我哈瓦2個css文件CSS需要辦理的html文件的不同部分

在一個CSS文件中我有風情
a{color: blue;} 在第二個文件我有 a{color: red;}

這些我想申請我的HTML文件

 <div> 
     <a>first file style </a> 
     </div> 
     <div> 
     <a>second file style </a> 
     </div> 

請建議,我怎樣才能...在此先感謝

爲什麼不使用不同的ID爲您<一個
+0

第一個文件的CSS將通過CSS的第二個文件被覆蓋......你想做什麼?如果你想對兩個錨點應用不同的CSS,然後申請類,並使用CSS ... –

+0

你想要達到什麼目的?首先'a'藍色和第二'''紅色?如果是的話,你不需要兩個文件 –

+0

不知道爲什麼你需要有兩個CSS文件,你不能只使用一個文件,並指定基於類或第n個元素? – llanato

回答

4

集類

HTML

<div> 
<a class="blue">first file style </a> 
</div> 
<div> 
<a class="red">second file style </a> 
</div> 

CSS

a.blue{color: blue;} 

a.red{color: red;} 
0

>?

HTML

<div> 
    <a id="firstlink">first file style </a> 
</div> 
<div> 
    <a id="secondlink">second file style </a> 
</div> 

CSS

#firstlink{ 
    color: blue; 
} 
#secondlink{ 
    color: red; 
} 
+0

ID將是最壞的情況下,許多鏈接有一個div ... –

+1

是的,當然,但如果他只需要這兩個鏈接它工作得很好.. 順便說一句,解決方案由路易斯PA提出的類對於可重用性肯定更好 – FredMaggiowski

相關問題