基本上,我需要找出所有支持CSS属性的HTML元素&background-color'和'颜色'在 Chrome 浏览器中。理想情况下,所有与颜色相关的CSS属性在级联和计算时都会产生差异。我尝试使用CSS.supports方法,但它很奇怪。 任何帮助将不胜感激。
答案 0 :(得分:0)
所有HTML元素都支持这些CSS属性:
var styleProperties = [
'color',
'backgroundColor'
];
var stylePropertiesLength = styleProperties.length;
var windowPropertyNames = Object.getOwnPropertyNames(window);
for (var i in windowPropertyNames) {
if (windowPropertyNames.hasOwnProperty(i)) {
var windowPropertyName = windowPropertyNames[i];
if (windowPropertyName.indexOf('HTML') === 0) {
var documentElement = document.createElement(windowPropertyName);
for (var j = 0; j < stylePropertiesLength; j++) {
var styleProperty = styleProperties[j];
var isSupported = (styleProperty in documentElement.style);
console.log(windowPropertyName + '.style.' + styleProperty + ' = ' + isSupported);
}
console.log('');
}
}
}