0

How can I get the inner div items to remain centered with complete scrolling capability?

Currently the content on the left hand side is truncated. The spacing of the items should not change and each inner div needs to remain it's own row.

See https://jsfiddle.net/mf89h3tg/13/. I have also pasted the code below.

.outer-div {
  display: block;
  overflow: auto;
  border-style: dashed;
  border-width: 2px;
  border-color: blue;
  margin: 100px;
}

.inner {
  display: flex;
  justify-content: center;
}
<div class="outer-div">
  <div class="inner">
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
  </div>
  <div class="inner">
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
  </div>
</div>

I've tried variations on the flex display to no avail.

j08691
  • 204,283
  • 31
  • 260
  • 272
zkongz
  • 44
  • 5

2 Answers2

0

You could use margin-inline: auto; to center the row.

See this CodePen if it solves your problem.

Torben
  • 86
  • 5
-1

Add the center tag let your button be inside of the tag

 <div class="outer-div">
  <div class="inner">
  <center>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
    <button>
      Hello
    </button>
  </div>
  <div class="inner">
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
    <button>
      World
    </button>
   </center>
  </div>
</div>