D
D
Dmitry2015-10-28 15:29:43
css
Dmitry, 2015-10-28 15:29:43

How to center a row of floating-width divs?

Hello. Help solve the problem.
There are divs with a fixed width of 630 pixels. It is supposed to display either 1 element by ~600 pixels, or two by ~300 or 3 by ~200. The problem is that the exact dimensions are not known in advance, and jscript is not allowed.
HTML snippet for two elements:

<div class="ban">
    <div class="pic">
        <img alt="" title="" src="#" width="300" height="120" border="0">
    </div>
    <div class="pic">
        <img alt="" title="" src="#" width="300" height="120" border="0">
    </div>
</div>

Adding other style options to pic is not suitable for the output (blocks with the pic class can be output in 1 2 and 3 instances according to the algorithm).
Elements inside the ban div must be spaced with the same padding between themselves and with zero at the edges

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2015-10-28
@Itachi261092

I slightly customized the variant from timtimIT
And it all worked.

A
Alexander Shtang, 2015-10-28
@Enclave88

How about flex: codepen.io/Enclave88/pen/PPeOyK

T
timtimIT, 2015-10-28
@timtimIT

Can it be like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question