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');}要做到各種瀏覽器兼容,你自己要去測試一下。
相關(guān)文章:
1. docker-machine添加一個已有的docker主機問題2. html - 用ajax提交表單后,返回驗證數(shù)據(jù)在頁面location.href跳轉(zhuǎn)到主頁,怎么傳遞session給主頁3. java-ee - JAVA的注解@Api和@ApiOperation的作用是什么,怎么跳轉(zhuǎn)頁面的4. apache - nginx 日志刪除后 重新建一個文件 就打不了日志了5. java - mybatis會自己緩存自己生成過的prestatement嗎6. angular.js - grunt server 報錯7. java - tomcat服務(wù)經(jīng)常晚上會掛,求解?8. java - 原生CGLib內(nèi)部方法互相調(diào)用時可以代理,但基于CGLib的Spring AOP卻代理失效,為什么?9. node.js - node express 中ajax post請求參數(shù)接收不到?10. mysql的主從復(fù)制、讀寫分離,關(guān)于從的問題
