title: Trying to apply CSS transform in javascript
body: <p>On my page I have an element that follows users cursor.
  What I'm trying to do is to use <code>transform</code> instead <code>top</code>/<code>left</code> with plain javascript. Without any libraries or depencies...
  The problem is that I need to apply values stored in variables to the transform property. I didn't find anything that could help me...
  Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var cursor = document.getElementById('cursor');
  document.body.addEventListener("mousemove", function(e) {
    //storing cursor position as variables
    var curX = e.clientX;
    var curY = e.clientY;
    
    
    // I need the code below to be replaced with transform-translate instead of top/left
    // I can not get this to work with any other method than top/left
    cursor.style.left = curX - 7 + 'px';
    cursor.style.top = curY - 7 + 'px';
      
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    background: orange;
    height: 500px;
    width: 500px;
  }
  #cursor {
      position: fixed;
      z-index: 20000;
      height: 14px;
      width: 14px;
      background-color: #222;
      border-radius: 50%;
      pointer-events: none!important;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
  &lt;div id="cursor"&gt;&lt;/div&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It's a simple or even a silly question but I have not found anything like this on stackoverflow or google...</p>