0

I currently have a set of panels that while in full screen a centered correctly, when they are at a small resolution, they are not. Basically I have a container with around 7 panels in it:

<div class"container">
    <div class="panel"></div>
    <div class="panel"></div>
    <div class="panel"></div>
    <div class="panel"></div>
    <div class="panel"></div>
    <div class="panel"></div>
    <div class="panel"></div>
</div>

I have created a code pen to show what it looks like in full screen: https://codepen.io/r3plica/pen/XemvyW?editors=0100

and in a small resolution (i.e. mobile) it looks like this: https://codepen.io/r3plica/pen/eGJOJN?editors=0100

I have made the background colour pink on the second codepen. I would like the items centering in the second pen without affecting the way it looks in a large resultion.

Does anyone know how I can achieve this?

Asons
  • 84,923
  • 12
  • 110
  • 165
r3plica
  • 13,017
  • 23
  • 128
  • 290

4 Answers4

1

Ok, I managed this:

https://codepen.io/r3plica/pen/OxMyPL?editors=0100#0

All I did was get rid of the flexbox on the container of the panels and updated the persona-panels to use margins with calc like this:

.persona-panels {
    > div {
        .panel {
            vertical-align: top;
            display: inline-block;
            margin: 7.5px calc((100% - #{$persona-panel-width}) / 2);

            @include large-width {
                margin: 7.5px;
            }
        }
    }
}
r3plica
  • 13,017
  • 23
  • 128
  • 290
0

There is a div with class ng-scope inside the flex-container. It blocks the code from being effective/working. Remove that from the html or make that your flex container. This is what your code actually looks like:

<div class="container">
   <div class="ng-scope DELETE THIS DIV">
      <div class="panel"></div>
      <div class="panel"></div>
      <div class="panel"></div>
      <div class="panel"></div>
      <div class="panel"></div>
      <div class="panel"></div>
      <div class="panel"></div>
   </div>
</div>

And in the css remove the inline-block from line 222 and it will center. Then add flex-flow: row wrap to .persona-panels.

H.W. Sanden
  • 153
  • 7
-1

Changing the display property on the panels is messing it up.

Flexbox's display property works differently in that it changes the children too, children then become flex items.

According to this answer, though, it's more practical to just use inline-block.

JackHasaKeyboard
  • 1,599
  • 1
  • 16
  • 29
-1

You have to remove property this property from .panel. then it will work fine

display-inline-block

Chander Shoor
  • 566
  • 1
  • 4
  • 8
  • no it won't because it will just force them all into 1 column – r3plica Sep 18 '17 at 12:29
  • This solution is not going to work. It destroys the layout for the full screen. Secondly, it would not be `display-inline-block`, but `display: inline-block`. – Binarus Sep 18 '17 at 12:34
  • The original poster has given links to his code in his original question. – Binarus Sep 20 '17 at 05:45