摘要
本文主要讲述了:
- CSS
- JavaScript
正文
CSS
- IE:
-ms-
- Firefox:
-moz-
- Edg:
-webkit-
- Chrome:
-webkit-
注意:通过 JavaScript 来操作元素的style
时,除了 IE 浏览器之外,其他浏览器都选择将 CSS 属性前缀的首字母大写
示例:
1 2 3 4 5 6
| #foo { -ms-transition: all 4s ease; -moz-transition: all 4s ease; -webkit-transition: all 4s ease; transition: all 4s ease; }
|
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Document</title> </head> <body> <div>hello, jsweibo</div> <script> document.querySelector('div').addEventListener('click', function () { console.log(this.style.msTransition);
console.log(this.style.MozTransition);
console.log(this.style.webkitTransition); console.log(this.style.WebkitTransition);
console.log(this.style.transition);
console.log(getComputedStyle(this)); }); </script> </body> </html>
|
JavaScript
- 如果整个 API 都是实验性质的,那么就在 API 的名称前加上前缀
- 如果 API 是标准的,但属性和方法是实验性质的,那么就在属性和方法的名称前加上前缀
API
- IE:
MS
- Firefox:
Moz
- Edg:
WebKit
(注意:K
为大写)
- Chrome:
WebKit
(注意:K
为大写)
示例:
1 2 3 4
| console.log(window.MSCSSMatrix); console.log(window.MozCSSMatrix); console.log(window.WebKitCSSMatrix); console.log(window.CSSMatrix);
|
属性和方法
- IE:
ms
- Firefox:
moz
- Edg:
webkit
- Chrome:
webkit
示例:
1 2 3 4
| console.log(window.msRequestAnimationFrame); console.log(window.mozRequestAnimationFrame); console.log(window.webkitRequestAnimationFrame); console.log(window.requestAnimationFrame);
|
参考资料
本文对你有帮助?请支持我