three columns per php row

1

Hi, I want to create a gallery of images where you define how many I want to see, and I want them to look at 3 per row using php

                                                       

<body>
    <div class="container-fluid">
        <?php
            $numeroGato=10;
            for ($i = 1; $i <= $numeroGato; $i++) {
                    echo "<div class='row'><img src='img/gato".$i.".jpg' class='mediana'></div>";
            }
        ?>
    </div>
</body>

at the moment I wear that and only look down

    
asked by callo33 02.10.2017 в 21:48
source

2 answers

0

Try this.

.container-fluid {
    display: flex;
    flex-wrap: wrap;
    margin-left: -4px;
    margin-right: -4px;
    width: 800px;
    padding: 2px;
    outline: 1px solid;
}
.container-fluid .row {
    width: calc(33.33333% - 8px);
    margin: 4px;
}

.row .mediana {
    display: block;
    width: 100%;
    height: auto;
}
    
answered by 03.10.2017 в 15:14
0

If you are using Bootstrap, it seems that if you use your own grid for it.

Remove the row in each image and put the class col-md-4 so that they add a total of 12 columns in width, that way 3 columns will be shown, and another 3 below.

<body>
    <div class="container-fluid">
        <?php
            $numeroGato=10;
            for ($i = 1; $i <= $numeroGato; $i++) {
                    echo "<div class='col-md-4'><img src='img/gato".$i.".jpg' class='mediana'></div>";
            }
    ?>
    </div>
</body>
    
answered by 05.10.2017 в 04:58