How to use Modernizr classes?

天涯浪子 提交于 2019-12-12 16:32:58

问题


I am new to modernizr. I read some documentation on modernizr, and I wanted to set border: none if browser doesn't support CSS3 box-sizing: border-box. I tried:

li { border-right: 1px solid #eee }
.css-boxsizing li { border: none }

But it didnt work out. Can any1 suggest something?


回答1:


In Modernizr, supported features are added as a class name to the root element. After inspecting the list of classes at http://modernizr.github.com/Modernizr/test/, I've found the correct class name to be boxsizing:

.boxsizing li { border: none }

In the default build, the boxsizing class seems not to be added. This can manually be added using Modernizr.addTest:

// The first argument is the class name
Modernizr.addTest("boxsizing", function() {
    return Modernizr.testAllProps("boxSizing") && (document.documentMode === undefined || document.documentMode > 7);
});​​​​​​

Demo: http://jsfiddle.net/eGjwZ/



来源:https://stackoverflow.com/questions/10057660/how-to-use-modernizr-classes

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