title: Using CSS calc() in JavaScript with a variable
body: <p>User NickC asks <a href="https://stackoverflow.com/questions/40871127/can-i-use-css-calc-withing-javascript">here</a> if it is possible to set an element's position (or similar style properties) in js using CSS's calc() function. </p>
  
  <p>Example:</p>
  
  <pre><code>var pad = "calc(1250px - 1000px)";
  element.style.paddingLeft = pad;
  </code></pre>
  
  <p>This shows up just fine on my web page, but I would like to include a js variable in the function, like so:</p>
  
  <pre><code>var pad = "calc("+ width +"- 1000px)";
  alert(pad); //displays calc( 1250px - 1000px)
  element.style.paddingLeft = pad;
  </code></pre>
  
  <p>I included the alert statement to assure myself that the string itself was correct, which it appears to be. However, the desired padding does not appear. </p>
  
  <p>Is there a problem with what I'm doing, or is it just not possible to do this?</p>