Detecting for -webkit-apperance with Modernizr

こ雲淡風輕ζ 提交于 2019-12-25 03:52:26

问题


Can anyone tell me how to detect -webkit-appearance, moz-apperance, or appearance using Modernizr?

I have custom selects, and checkboxes that use these and I need to ensure the additional styles are not applied on those browser that dont support these properties.

Thanks


回答1:


I'm pretty certain that Modernizr doesn't include a detection routine for this feature yet -- it's just too new.

However, as it's a CSS property, you should be able to detect it fairly simply for yourself without needing to invoke modernizr.

This page details how to do a quick check to detect if a CSS property is available.

Simply check whether the property exists in the style property of any given DOM element. If the property is supported, it will be in the DOM, even if it isn't actually set to anything.

Hope that helps.




回答2:


Just use Modernizr.testProp() method:

Modernizr.testProp('webkitAppearance'); 

And with this check you can write your own Modernizr test using Modernizr.addTest():

Modernizr.addTest('webkit-appearance', function() {
    return Modernizr.testProp('webkitAppearance');
});


来源:https://stackoverflow.com/questions/13615963/detecting-for-webkit-apperance-with-modernizr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!