-2

I use Elementor in WordPress. I have 2 grid rows 2 separate div. It must be this way.

On large screens (1500) I want to have 4 columns And in smaller screens (1100) that will have 3 columns.

You can see in the following link an illustration of the problem: rows 4 and 8 are shown alone in the second row

https://jsfiddle.net/t7ku9c2q/

How can this problem be solved so that all the lines are displayed inline?

Again - it must be in 2 divs! There is no other way to do it

Code:

* {
  box-sizing: border-box;
}

.wrapper {
  display: flex;
  flex-wrap: wrap;
}

.wrapper>* {
  padding: 1em;
  background-color: grey;
  border: 1px solid black;
  flex: 0 1 25%;
}

@media (max-width: 1200px) {
  .wrapper>* {
    flex: 0 1 33.33%;
  }
}
<div class='wrapper'>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
</div>
<div class='wrapper'>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
</div>
tacoshy
  • 10,642
  • 5
  • 17
  • 34
qwerty
  • 3
  • 3

1 Answers1

0

Much as I dislike floats, I think in this case they're your best solution. (I tried various flexbox ideas, but none of them worked.)

* {
    box-sizing:border-box;
}

.wrapper {
    display:inline;
}

.wrapper > * {
    padding:1em;
    background-color:grey;
    border:1px solid black;
    width:33.33%;
    float:left;
}

@media (min-width:1200px) {
    .wrapper > * {
        width:25%;
    }
}   
Kate
  • 176
  • 5
  • Hi, I'd really love to know if this helped you! Could you give a quick update please? – Kate Jun 04 '21 at 18:21