找到解决办法! 这一职能将很少发挥 j色挑选器的作用,扫描你所有的风格表,过滤影响所赋予的OMS要素的规则,将这些规则加以规范,并将一份附有特别安全局规则清单的物体从所涉所有遗产的相互作用中收回。
<style type="text/css">
.fool{
margin-left:200px;
}
#fool{
margin-left:auto;
}
</style>
<div id="fool" class="fool" style="font-size:100px; height:20px;"></div>
<script type="text/javascript">
jQuery( document ).ready(function($){
function get_inheritance_result(jQueryElement){
var styleSheets = document.styleSheets, finalRules = {};
for(var i in styleSheets) {
var rules = styleSheets[i].rules || styleSheets[i].cssRules;
for(var r in rules) {
var selector = String(rules[r].selectorText);
if(selector.indexOf( : ) == -1){ //ignoring pseudo selectors, they will not matter here
if(jQueryElement.is(selector.toString())) {
console.log(selector.toString()); // Will log all the selectors that are affecting the particular DOM element
finalRules = $.extend(finalRules, rules[r].style);
}
}
}
}
//taking any inline css and overriding it on top of our finalRules variable:
var inlineCSS = jQueryElement.prop( style );
for(i in inlineCSS){
if(inlineCSS.hasOwnProperty(i)){
if(inlineCSS[i] != ""){
finalRules[i] = inlineCSS[i];
}
}
}
//and voila!
return finalRules;
}
var style = get_inheritance_result($("#fool"));
console.log(style); //logs all the resulted css rules
alert(style.marginLeft); // auto !
alert(style.fontSize); // 100px !
});
</script>
www.un.org/Depts/DGACM/index_spanish.htm 由于提出了这一问题,学会了许多努力解决这一问题的经历。