N
N
Neuro2019-05-29 15:52:05
css
Neuro, 2019-05-29 15:52:05

How to center blocks in parent?

Good afternoon, I encountered such a problem that on mobile devices and tablets, the blocks are displaced and an empty space appears as in the screenshot
5cee7f8fe9fc1301860059.png
. Is it possible to somehow center the blocks, if they are displaced, so that there is no "gap"?
Here is the css

spoiler
.section-quickSearch {
      max-width: @max-width;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      margin: 0 auto;
      padding: 2.8125rem 0 0;
      border: 1px solid red;

      .quickSearchs {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid green;

      .quickSearch-wrapper {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        width: 18.75rem;
        margin-left: 1rem;
        margin-right: 1rem;
        margin-bottom: 2rem;
        background: #FCFCFC;
  }
 }
}

The ideal solution would be instead of justifu-content: flex-start; use justifu-content: center; but then the block is set to the center of the parent.
How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Neuro, 2019-05-29
@Riveran

Found a solution
Green block (quickSearch), you need to add a pseudo element with a fixed width.

&:after {
  content: "";
  flex: 1 1 100%;
  max-width: 333px;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question