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. win10 Apache24+PHP8.0,Apache不能正常加載php.ini。2. python - (2006, ’MySQL server has gone away’)3. python - PyCharm里的一個文件不小心忽略了wx包4. http - python requests上傳文件問題5. javascript - 關于微信掃一掃的技術問題6. python - 使用eclipse運行django代碼,修改了views.py這個文件,但是瀏覽器顯示的還是原有沒修改的結果,怎么處理?7. 小白學python的問題 關于%d和%s的區別8. django - pycharm 如何配置 python3 的開發環境?9. html - Python2 BeautifulSoup 提取網頁中的表格數據及連接10. android - VideoView與百度Map沖突
