0

I like to have a div that keeps all it's children in the center (vertical and horizontal). I can easily achieve this by using flexbox. But when my children width get bigger than the parent, overflow: scroll does not work

Codepen

Anybody know why and how can be fixed?

Update

My issue has been fixed. BUT, when I add a content to children, the content not showing correctly.

.container {
  height: 500px;
  width: 500px;
  background: red;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: scroll;
}

.children {
  min-width: 1200px;
  height: 50px;
  background: blue;
}
<div class='container'>
  <div class="children"><h1>Welcome to my city, California</h1></div>
</div>
Arian Nargesi
  • 506
  • 1
  • 4
  • 13

1 Answers1

1

It looks like the child object is not actually 1200px - it's getting squished down to 500px. However, if you set min-width: 1200px; in the child component, it seems to override this and produces the behavior you expect.

chase
  • 317
  • 2
  • 9