CenteredDivScrollOverflowProblem - 1

A perfectly centered div with the "translate trick" applied. When this div becomes larger than it's container a part of the top and the left of the div are not reachable / viewable anymore.

by Joep Greuter

HTML

<div id='container'>
  <div id='content'>
    <p>
      centered...
    </p>
  </div>
</div>

CSS

#container{
  position: relative;
  width: 400px;
  height: 400px;
  background-color: gray;
  overflow: auto;
}

#content{
  position: absolute;
  width: 500px;
  height: 500px;
  top: 50%;
  left: 50%;
  border: 1px solid red;
  transform: translate(-50%, -50%);
}