How can I wrap a container around its css-transfor

2020-07-20 08:05发布

问题:

When I use scale or rotate, the parent element wraps to the size of the pre-translation dimensions of the element.

JSFiddle Example

Is there any way to wrap the parent container around the bounding box of the transformed element with CSS, or do I need to use Maths to manually position things?

回答1:

Based on this earlier question it sounds like you will need to use some math and javascript to change the wrapper.

By using the function in the answer you could then set the wrapper dimensions based on the dimensions you just calculated.