title: Designating type of input going in a .css() method in a JQuery Id Selector
body: <p>So I've got a element that needs to sit underneath an anchored toolbar. And the amount of top-padding necessary to get it underneath said toolbar changes based on the width of the viewport. So I've developed a formula to determine the percent of padding-top needed at any point in time from 2560px down to 320px, the largest and smallest viewport widths our software caters to, but I'm struggling to actually get it into a css style.</p>
  
  <p>This is what I'm working with right now.</p>
  
  <pre><code>getTopPadding = (): void =&gt; {
          var x: number = $(window).width(),
              paddingPercent: number = ((0.007589 * (2560 - x)));
          if (paddingPercent &lt; 5) {
              paddingPercent += 5;
          }
  
          $('#appendHere').css('padding-top', paddingPercent);
      };
  </code></pre>
  
  <p>So I've got this formula that takes my current width and pumps out what the padding-top should be. So for example, on a width of 320px, padding needs to be,      </p>
  
  <pre><code>padding-top: 17%;
  </code></pre>
  
  <p>paddingPercent will calculate the number 17 just fine, but if I pass in just paddingPercent as a value for the .css() method it comes out like this</p>
  
  <pre><code>padding-top: 17px;
  </code></pre>
  
  <p>So what I'm trying to find out is, is there a way to designate whether the value I'm passing in should be px, em, vw, or %? I've tried</p>
  
  <pre><code>$('#appendHere').css('padding-top', (paddingPercent + '%'));
  </code></pre>
  
  <p>thinking perhaps taking the number and adding a string to the end would add the % symbol I need and stringify the value because you can pass a string in to the .css() method. But thinking about it more I realized the reason it accepts a string is more for things like specifying color etc, not for what I'm doing. I thought about type casting and doing </p>
  
  <pre><code>Number((paddingPercent + '%'));
  </code></pre>
  
  <p>But that would come back with NaN, so I'm not sure where to go from here. Hoping someone can offer some insight.</p>