title: How to calculate scale value to fit a rotated element inside parent in CSS3
body: <p>How can we calculate the scale value required to fit rotated element (img) inside its parent (div). Looking for a code that will work for any value of rotate.</p>
  
  <pre><code>&lt;style&gt;
  img{
  transform: rotate(20deg);
  }
  &lt;/style&gt;
  
  &lt;div&gt;
    &lt;img src="image.jpg" /&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  //open to JS solution
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/h05Lk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h05Lk.png" alt="What is required"></a></p>