Flex-box wraps two windows when scaling a browser window

We have four children in one parent. And I want to make the effect that you see in the picture.

<article class="parent">
<figure class="child">
    <img src="img/example.jpg" alt="" />
    <figcaption">
        <p>description</p>
    </figcaption>
</figure>
<figure class="child">
    <img src="img/example.jpg" alt="" />
    <figcaption">
        <p>description</p>
    </figcaption>
</figure>
<figure class="child">
    <img src="img/example.jpg" alt="" />
    <figcaption">
        <p>description</p>
    </figcaption>
</figure>
<figure class="child">
    <img src="img/example.jpg" alt="" />
    <figcaption">
        <p>description</p>
    </figcaption>
</figure>
</article>

The child has one constant parameter width: 300 pixels;

But we cannot edit html (+ div).

We can only use CSS for this thing. Is it possible?

example in picture

My English is bad:)

+1
source share
2 answers

Maybe something like this? https://codepen.io/jnnkm/pen/jVwZrX

.parent {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 800px;
}

@media only screen and (min-device-width: 1000px)  {

  .parent {
    width: initial; 
  }
}
0
source

Good evening The Agropl!

, , - flexbox, , , .:)

http://codepen.io/andreastherkildsen/pen/pNeajo

<div class="flex-container">
  <div class="flex-item">
    <h3>1</h3>
    <p>Lorem ipsum, Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,</p>
  </div>
  <div class="flex-item">
     <h3>1</h3>
    <p>Lorem ipsum, Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,</p>
  </div>

  <div class="flex-item">
     <h3>1</h3>
    <p>Lorem ipsum, Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,</p>
  </div>

  <div class="flex-item">
     <h3>1</h3>
    <p>Lorem ipsum, Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,Lorem ipsum,</p>
  </div>
 </div>

.flex-container{
  height: 500px;
  background: blue;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  align-items:  baseline;
  -webkit-flex-flow: row wrap;
  justify-content: space-around;

}

.flex-item{
  background: tomato;
  width: 300px;
  height: auto;
  margin-top: 10px;
  color: white;
  font-weight: bold;
  text-align: center;
  display: flex;
}

.flex-item h3{
  font-size: 50px;
  padding-left: 50px;
}

.flex-item p{
  font-size: 16px;
  padding-left: 50px; 
}

@media all and (max-width: 1230px) {
  .flex-item{
    padding-right:100px;
  }
}
0

Source: https://habr.com/ru/post/1661963/


All Articles