忽略CSS标记
我想知道是否有一种方法可以忽略标记:忽略CSS标记,css,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 foll
<!-- 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>
运输署分区{
颜色:#555555;
字号:10pt;
文本对齐:左对齐;
}
试验
我想知道是否有什么我可以添加跳过这些通用div/td样式。e、 g.
#myapp div{font-color:inherit;}
这将继承红色
#myapp div{
color: inherit;
}
没有直接的CSS方法可以忽略以后的CSS规则 最可靠的选择是使用JavaScript删除标记 示例:移除
元素后的第一个
标记:
<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>
setTimeout(函数(){
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){
//删除样式元素=>禁用样式
elem.parentNode.removeChild(elem);
//删除临时脚本元素
script.parentNode.removeChild(脚本);
打破
}
}
}
}, 4);
... 除了样式元素之外的任何东西。。。
/*我想阻止这些规则被使用*/
@BoltClock我的意思是我想忽略通用CSS标记(在我可以在这里添加代码之后)。