I understand that CSS transforms don't affect the effective size of an element, just its visual presentation. The following posts discuss this:
- CSS Scale transform on child not affecting parent size
- CSS transform: scale does not change DOM size?
I also see the following discussions that don't quite discuss overflow distance:
I am trying to wrap an element which has been scaled inside another element with overflow set to scroll.
The issue is that because CSS scaling does not affect the actual size of an element, just its visual presentation the scroll overflow is set to the original dimensions of the element, which is either too large or too small
Is there a method of explicitly setting the overflow distance on the parent to work around this issue? That might allow me to do something like setting the overflow height to the child height * scale
and the width to child width * scale
on the parent.
I expect the actual scaling value to change via user input, dynamically resizing the element on the fly.
Below is an example snippet of the issue in action.
.parent {
overflow: scroll;
height: 500px;
width: 500px;
background: black;
}
.child {
background-image: url("https://i.redd.it/7ifkx5z39b631.jpg");
transform: scale(0.25, 0.25);
transform-origin: top left;
height: 7000px;
width: 4900px;
}
<div class="parent">
<div class="child">
</div>
</div>