S
S
scarards2019-10-31 21:01:54
Flexbox
scarards, 2019-10-31 21:01:54

Is it possible to use flex-wrap with a rigid container?

Hello, please tell me how to use flexbox, provided that there is a container whose width is set in pixels. For example code:

<section>
        <div class="container">
            <div class="wrap-list">
                <div class="wrap-item"></div>
                <div class="wrap-item"></div>
                <div class="wrap-item"></div>
                <div class="wrap-item"></div>
            </div>
        </div>
    </section>

.container{
    width: 1100px;
    margin: 0 auto;
}
.wrap-list{
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.wrap-item{
    width: 250px;
    background-color: #000;
    height: 100px;
}

In this case, flex-wrap does not work, and if you specify the width of the container in%, then everything works out.
Is it possible somehow to use flex-wrap with a width in pixels, or should I use something else in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2019-10-31
@scaards

There are 2 options here:
1. Use grids
2. Wrap a fixed container in another flex container, but without a fixed width.
For example, like
this in this case section will be a full-width flex container, and wrap-list is already a fixed container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question