2011-11-11 53 views
0

給定一個我想要集成到cms站點的表格,整個樣式表將覆蓋表格的內聯樣式......我如何防止樣式表執行此操作? 表我有看起來像這樣,並得到由樣式表覆蓋...有沒有簡單的方法來覆蓋樣式表內聯樣式?

<table id="idferthis" BORDER=1 RULES=NONE FRAME=BOX width="644" border="1" cellspacing="1" cellpadding="5"> 
    <tr> 
    <th id="toptopper" bgcolor="#6a8044" align="right" scope="row">HIPHOO</th> 
    <td bgcolor="#afd46c" align="center">SOMETHIN</td> 
    <td bgcolor="#afd46c" align="center">SOMETHINELSE</td> 
    </tr> 
.... 
</table>  

非常感謝!

+0

爲什麼使用內聯樣式而不是樣式表? – Zirak

+1

可能重複[覆蓋屬性在「style =」屬性?](http://stackoverflow.com/questions/1933248/override-property-in-style-attribute) –

+0

@Zirak ...因爲我太懶惰翻譯把表格轉換成適當的CSS ......並且這裏有很多這樣的表格......; -P – Jurudocs

回答

3

在您想要覆蓋的元素後嘗試此操作

!important;

這樣一個例子是

<td style="color:#000; !important;">Black Text</td> 

這將重寫的樣式表與黑色文本。

1

嘗試使用style屬性爲表,

這意味着style="border-width:1; width:644px; ..."

1

使用CSS規則的樣式表格,內聯CSS優先於包括在內。

例如,而不是使用bgcolor屬性,使用背景色CSS屬性,例如:

<td style="background-color: #afd46c;" align="center">SOMETHINELSE</td> 
0

CSS文件中寫一個樣式呈現的控制和應用!important的風格。

例如,

table td {background-color: red !important;}