0

I am new to flexbox and now I am trying to align items both vertically and horizontally. I started to google and found quite enough answers. All of them are based on the same strategy: to add some css rules to parent block:

display: flex;
align-items: center;
justify-content: center;

But I also want so that parent block was 100% height of window. So I made 100% of html, body and parent block. From the first sight everything works. But then I noticed a problem. When I shrink a browser so that child block does not fit browser window, top part of child centerd block is not visible.

Here is an example. When you open it you see red top border. But if you decrease size of the area for displaying so that the square does not fit that area you do not see a top border. It is lost.

I saw this answer but the problem also exists in the first accepted answer. What should I do to resolve this?

Update

Here is what I get: enter image description here

FreeLightman
  • 2,224
  • 2
  • 27
  • 42

0 Answers0