Having an absolutely placed and perfectly centered ("translate trick") div within a container: jsfiddle.
<div id='container'>
<div id='content'>
<p>
centered...
</p>
</div>
</div>
#container{
position: relative;
width: 400px;
height: 400px;
background-color: gray;
}
#content{
position: absolute;
width: 100px;
height: 100px;
top: 50%;
left: 50%;
border: 1px solid red;
transform: translate(-50%, -50%);
}
Now when this inner div becomes larger than it's container and the container has overflow: auto (scroll). It becomes impossible to get the utmost top and left part of the inner div to become visible within the container by scrolling it to the left and top and its maximum: jsfiddle.
#container{
...
overflow: auto;
}
#content{
...
width: 500px;
height: 500px;
...
}
The "same" thing happens when the inner div is scaled to a proportion that it overflows the container div: jsfiddle.
#container{
...
overflow: auto;
}
#content{
...
transform: ... scale(5);
}
Any ideas on how to have the inner div stay centered and still be able to reach all its area by using the scrollbars of the container div? Or should the "centeredness" be dropped when the size overflows the container (possibly using javascript)? A pure css solution is much preferred.