css3 - 怎么判断浏览器是否支持translate3d
问题描述
transform之类的可以for in检测出来,但是translate3d要怎么检测呢?
问题解答
回答1:function has3d() { if (!window.getComputedStyle) {return false; } var el = document.createElement(’p’), has3d,transforms = { ’webkitTransform’:’-webkit-transform’, ’OTransform’:’-o-transform’, ’msTransform’:’-ms-transform’, ’MozTransform’:’-moz-transform’, ’transform’:’transform’}; // Add it to the body to get the computed style. document.body.insertBefore(el, null); for (var t in transforms) {if (el.style[t] !== undefined) { el.style[t] = 'translate3d(1px,1px,1px)'; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);} } document.body.removeChild(el); return (has3d !== undefined && has3d.length > 0 && has3d !== 'none');}要做到各种浏览器兼容,你自己要去测试一下。
相关文章:
1. boot2docker无法启动2. docker-compose中volumes的问题3. java - SSH框架中写分页时service层中不能注入分页类4. docker容器呢SSH为什么连不通呢?5. dockerfile - 为什么docker容器启动不了?6. docker安装后出现Cannot connect to the Docker daemon.7. nignx - docker内nginx 80端口被占用8. node.js - antdesign怎么集合react-redux对input控件进行初始化赋值9. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””10. 关于docker下的nginx压力测试

网公网安备