2012-03-12 123 views
0

想知道是否有是忽略標籤的方式:忽略CSS標籤

<!-- I can add code here --> 

<!-- I cannot edit the following start --> 
<style> 
    div, td { 
    color: #555555; 
    font-size: 10pt; 
    text-align: left; 
    } 
</div> 
<!-- I cannot edit the following end --> 

<div id="myapp" style="color:red"><div>Test</div></div> 

想知道如果有什麼我可以添加跳過這些通用DIV/TD風格。例如#myapp div { font-color: inherit; }

+0

你是什麼意思的 「標籤」 嗎? – BoltClock 2012-03-12 15:09:02

+0

@BoltClock我的意思是我想忽略通用的CSS標籤(在這裏我可以添加代碼)。 – 2012-03-12 15:15:46

回答

0

這將繼承紅色

#myapp div{ 
    color: inherit; 
} 
2

有沒有簡單的方法CSS以後忽略CSS規則。

最可靠的選擇是使用JavaScript刪除標籤。

:在<script>元素後刪除,也就是說,第一<style>標籤:

<script id="unique-id-script"> 
setTimeout(function() { 
    var removeTheNthStyleElement = 1, found = 0, 
     script = document.getElementById('unique-id-script'), elem = script; 
    while (elem = elem.nextSibling) { 
     if (elem.nodeName.toUpperCase() === 'STYLE') { 
      if (++found === removeTheNthStyleElement) { 
       // Remove style element => disable styles 
       elem.parentNode.removeChild(elem); 
       // Remove temporary script element 
       script.parentNode.removeChild(script); 
       break; 
      } 
     } 
    } 
}, 4); 
</script> 
... anything but a style element... 
<style> 
/* I want to prevent these rules from being used */ 
</style>