-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第 9 期(2019-05-16):CSS兼容性验证 #11
Comments
答案参考: CSS 模块的侦测 function isPropertySupported(property) {
if (typeof property === 'string') {
if (property in document.body.style) return true;
const prefixes = ['Moz', 'Webkit', 'O', 'ms', 'Khtml'];
const prefProperty = property.charAt(0).toUpperCase() + property.substr(1);
for (let i = 0; i < prefixes.length; i++) {
if ((prefixes[i] + prefProperty) in document.body.style) return true;
}
return false;
} else if (property === undefined) {
let result = [];
for (let i in document.body.style) {
result.push(i);
}
return result;
}
} |
返回的CSS属性名还是驼峰体,不对哦~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
封装一个特性检测函数,用以验证当前浏览器是否支持某个 CSS 属性
测试用例: (以下结果来自 Chrome 74)
参考答案:
本期优秀回答者: 无 [哭笑.jpg]
The text was updated successfully, but these errors were encountered: