title: Calculate the width of a rotated div based on window height and window width and desired empty space
body: <p>I need to calculate the width of a rotated div using only the window height and width, so that it only leaves room for an empty triangle in the top left and the bottom right of the webpage.</p>
  <p>Something like this (red part is the rotated div):</p>
  <p><a href="https://i.stack.imgur.com/20vur.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/20vur.png" alt="enter image description here" /></a></p>
  <p>The problem I have is that the calculation for the correct width needs to work for every window width and height combination. I am convinced this is possible using trigonometry, but it's been quite a while since I actually worked with sin/tan/cos/etc. and so far nothing I tried really worked, so I need some help/pointers.</p>
  <p>To summarize what I want to achieve:</p>
  <ul>
  <li><p>There should be an empty triangle top left with an angle of 55 degrees and a height of 150px;</p>
  </li>
  <li><p>There should also be an empty triangle bottom right with the same dimensions as above</p>
  </li>
  <li><p>There should be a div that gets rotated like this:</p>
  <p>transform: rotateX(45deg) rotateZ(45deg);
  transform-origin: top left;</p>
  </li>
  <li><p>The only thing that should be changed about the rotated div is the &quot;width&quot; css attribute. This values should change depending on the window height and width (these are the only variables).</p>
  </li>
  </ul>
  <p>I have tried multiple things, but I just can't figure it out. Here is my lastest attempt (try changing window size to see the problem):</p>
  <p><a href="https://codesandbox.io/s/relaxed-shtern-qphkj" rel="nofollow noreferrer">https://codesandbox.io/s/relaxed-shtern-qphkj</a></p>
  <p>As you can see I managed to always have the exact same top left triangle regardless of window height and width. The problem is the bottom right triangle, that either gets overlapped by the rotated div (aka rotated div is too wide) or the empty triangle gets too large (aka the rotated div isn't wide enough).</p>
  <p>Any ideas or pointers would be appreciated.</p>