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. docker容器呢SSH為什么連不通呢?2. docker - 如何修改運行中容器的配置3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. docker start -a dockername 老是卡住,什么情況?5. Android TextView 或 ListView 加載過渡效果6. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?7. python - thrift 返回 TSocket read 0 bytes 求助!!!!8. python3.x - python中import theano出錯9. python - (初學者)代碼運行不起來,求指導,謝謝!10. python - django模板 include模板的數據問題
