I have a rotated div contained inside a box, and want the outside div to contain the rotated children exactly. Here's an example:
<div class="container"> <div class="box"/> </div> .box { content: ''; background-color: red; width: 100px; height: 100px; transform: rotate(45deg) } .container{ margin: 3rem; display: inline-block; border: 5px solid black; // padding: 19px; } This looks like this:
Adding the padding (commented above), I can approximate the result I want, which is this:
The problem is that it is not exact, and it is hard-coded instead of automatic.

