How TO - Align Images Side By Side

Brandon T

How they show up nowI am following this tutorial on w3schools. I am creating a social site and I want to show users an explore page and I want the images to be side by side maybe 3 or 4 pics a row and then break and then show another 3 or 4. Right now it's completely off. How it shows.

As you can see, it is on top of each other and it is all on the right side of the page. What am I missing ? I want it to show exactly how it looks on the example.

<div class="row">
<?php

    // output data of each row
    while ($explore_image->fetch()) {

        if ($userLoggedIn != $added_by) {

            if (!empty($image)) {
                echo '<div class="row"><div class="explore_column">';
                echo "<a href='$image'><img src='$image' ></a><p> $added_by $likes </p></br><br><br><br></div></div><br>";
            }
        }
    }
    
    $explore_image->close();
    $con->close();

?>
</div>
* {
box-sizing: border-box;
}

.row {
display: flex;
}

/* Create three equal columns that sits next to each other */
.explore_column {
flex: 100.33%;
padding: 5px;
}

@media screen and (max-width: 500px) {
.explore_column {
width: 100%;
}
}

/* Three image containers (use 25% for four, and 50% for two, etc) */
.explore_column {
float: left;
width: 33.33%;
padding: 5px;
}

/* Clear floats after image containers */
.row::after {
content: "";
clear: both;
display: table;
}
Jakub A Suplicki

You could try to implement styling as below:

div {
  display: flex;
  flex-wrap: wrap;
}
img {
  flex: 1 0 20%;
  width: 20%;
  margin: 5px;
}
<div>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
  <img src="https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg"/>
</div>


You can adjust the % to your needs.

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

How do you "stick" images on the side of the website, and align text to that image?

How can I align these elements side by side?

is there a way to align two HTML elements side by side without CSS? How?

How to align nav item to the right side in a navbar?

How do I place two or more ASCII images side by side?

How to change the order of columns and plot images side by side with seaborn in Python?

Vertically align buttons with wrapped text, side by side

1 image vs 2 images side by side

How to align Material Design Lite cards to right hand side

How to align the text on the right side of the value box in R shiny?

Align tables to each others side

How to print output side by side?

How to make images appear side by side on one row on desktop, but responsive and centered above each other on mobile?

Align two divs side by side covering entire page width

Align two unordered lists side by side starting at the top

Align text to the right side of a button radio

CSS align few items on both side with flexbox

Unable to align div to right side Flexbox

Align text under left side of image

undetermined number of images, side by side, to fit container width

PHP GD library, turn 2 images into 1 side by side

how to make profile cards side by side?

How to place 2 algorithms side by side?

How to put input and dropdown side by side in Bootstrap?

How to get these two divs side-by-side?

How to get side by side data by day?

How to open SwiftUI preview side by side to the code?

How to compare two mysql tables side by side

How to Center 2 Divs Side by Side

TOP lista

quentelabel

Arquivo