10-XX-matrix-2d-transform.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Simple transform</title>
  6. <style>
  7. /**
  8. * 1. Prefixes are required for a lot of older browsers. Depending on
  9. * how essential it is to support legacy browsers, you may need all
  10. * or some of these - check http://caniuse.com for current browser support.
  11. * In this case, we’ve only used the standardized property to keep it
  12. * readable.
  13. */
  14. .box {
  15. width: 100px;
  16. height: 100px;
  17. margin-top: 20px;
  18. position: absolute;
  19. top: 200px;
  20. left: 200px;
  21. background-color: #eee;
  22. outline: 1px solid;
  23. transform: matrix(1.4142135623731,
  24. 1.4142135623731,
  25. -1.16484955484288,
  26. 1.66357756990331,
  27. 70.7106781186548,
  28. 70.7106781186547); /* 1 */
  29. /* equivalent to:;
  30. transform: rotate(45deg)
  31. translate(100px, 0)
  32. scale(2)
  33. skewX(10deg); */
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div class="box" id="matrixed"></div>
  39. <button type="button" id="showstyle">Press me to show the computed transform style of the box!</button>
  40. <script>
  41. document.getElementById('showstyle').onclick = function () {
  42. alert(window.getComputedStyle(document.getElementById('matrixed')).transform);
  43. };
  44. </script>
  45. </body>
  46. </html>