I have an element that I need to center on the page on both axis. I'm trying to use the flexbox for this, however, when the element's container overflows (e.g. the browser window is too small to fit the entire element), the element's content is getting truncated from left and top without the ability to scroll and see the entire content:
body {
margin: 30px;
}
.resizer {
border: 1px dashed black;
resize: both;
width: 400px;
height: 400px;
overflow: auto;
display: flex;
align-items: center;
justify-content: center;
background-color: #888;
}
.centered {
flex: 0 0 300px;
background-color: lime;
}
<div class="resizer">
<div class="centered">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in imperdiet justo, a porttitor lectus. Suspendisse vel tempor arcu, a pretium lectus. Ut et magna vitae purus porta egestas at ut elit. Nulla faucibus nibh sed purus pulvinar, in dictum est vestibulum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec varius placerat dolor, non commodo purus malesuada eget. Fusce congue non erat ullamcorper ultricies. Fusce sed tellus lectus. Aenean quis maximus augue, eu placerat urna.
</div>
</div>
It looks like the browser is calculating overflow only in a single direction (bottom-right).
Is it possible to make the entire content accessible on overflow without using media queries?