Get element's transform property with Javascript

I want to rotateY an element with Javascript.

The problem being, when I change the transform property of the element: = "rotateY(10deg)";

I override all transform properties the element had.

var element = document.querySelector('.element'); = "rotateY(10deg)";

/* Overrides all transforms specified in CSS! */
.element {
  width: 100px;
  height: 100px;
  background: orange;
  /* Overriden! */
  transform: scale(1.1) rotateX(10deg) rotateY(10deg) translate(10px, 10px);
<div class="element"></div>

My attempts at solving the problem have been fruitless.

First, I attempted getting the element’s transform properties (to change only rotateY) with

var element = document.querySelector('.element');


/* Cannot log styling because it's not inline! */
.element {
  width: 100px;
  height: 100px;
  background: orange;
  /* Cannot access.. */
  transform: scale(1.1) rotateX(10deg) rotateY(10deg) translate(10px, 10px);
<div class="element"></div>

However, this ended up impossible, because .style only works for elements with inline style declarations (<div style="transform:rotateY(10deg)">).

Second, I attempted to retrieve the styling through Window.getComputedStyle():

var element = document.querySelector('.element');

var style = window.getComputedStyle(element);

/* Gives "matrix3d"...? */
.element {
  width: 100px;
  height: 100px;
  background: orange;
  /* Cannot access! */
  transform: scale(1.1) rotateX(10deg) rotateY(10deg) translate(10px, 10px);
<div class="element"></div>

However, getComputedStyle() returns not the original style declarations, but rather a matrix3d, which I could not find a way to read.

Lastly, I tried searching the web.

All the questions that I found are listed below. They do not offer how to read 3d transforms.

All of them feature complicated manipulations on the matrix (2d) value.

My question is: Can I read an element’s transform properties?

Maybe this is done through reading the matrix3d value. Or maybe some other way to retrieve styling that I don’t know?

I will be grateful for answers on the subject.

300 thoughts on “Get element's transform property with Javascript”

  1. Pingback: buying viagra
  2. Pingback: viagra for women
  3. Pingback: sildenafil 1000 mg
  4. Pingback: levitra drug class
  5. Pingback: lasix renogram
  6. Pingback: xenical 84
  7. Pingback: nolvadex mexico
  8. Pingback: naltrexone lab
  9. Pingback: tizanidine coupons
  10. Pingback: cialis extraforrel
  11. Pingback: tadalafil uses
  12. Pingback: cialis daily pill
  13. Pingback: 40 mg sildenafil
  14. Pingback: herbal viagra
  15. Pingback: 200 mg viagra
  16. Pingback: sildenafil 100mg
  17. Pingback: sildenafil online
  18. Pingback: viagra connect
  19. Pingback: viagra for sale
  20. Pingback: sildenafil 20mg
  21. Pingback: buy cialis uk
  22. Pingback: viagra sale
  23. Pingback: viagragates
  24. Pingback: cialis samples
  25. Pingback: 20mg cialis
  26. Pingback: buy generic viagra
  27. Pingback: cost of viagra
  28. Pingback: generic for viagra
  29. Pingback: viagra gel uk
  30. Pingback: cialis wirkung
  31. Pingback: taking viagra
  32. Pingback: herbal viagra
  33. Pingback: womens viagra
  34. Pingback: cheap viagra
  35. Pingback: amoxil for uti
  36. Pingback: viagra prices
  37. Pingback: furosemide canada
  38. Pingback: neurontin 200 mg
  39. Pingback: buy quineprox
  40. Pingback: modafinil cvs
  41. Pingback: what is zithromax
  42. Pingback: viagra ohne rezept
  43. Pingback: neurontin 200
  44. Pingback: quineprox 75 mg
  45. Pingback: women take viagra
  46. Pingback: buying provigil
  47. Pingback: buying ventolin uk
  48. Pingback: viagra vs.levitra
  49. Pingback: viagra sildenafil
  50. Pingback: sildenafil citrate
  51. Pingback: viagra substitute
  52. Pingback: viagra online
  53. Pingback: levitra vs cialis
  54. Pingback: lumigan glaucoma
  55. Pingback: cost of aralen
  56. Pingback: otc tizanidine
  57. Pingback: clomid in india
  58. Greetings! Very useful advice in this particular post! It is the little changes which
    will make the greatest changes. Many thanks for sharing!


Leave a Comment