The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS 3-Column photo grid

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #198125

    I usually know how to do this just fine but in this case I don’t because my code here:

    <div class="img-gallery">
        <div class="gallery-photos">
            <ul class="gallery-portfolio">
                    $dirname = "uploads/";
                    $images = glob($dirname."*.png");
                    foreach($images as $image) {
                    echo '<li><img src="'.$image.'" class="img-responsive" alt="Responsive image" /></li><br />';}

    This makes it so that all of the uploaded photos from my website will be added automatically but I am unsure with the tags I have there, how to style them the way I want. I have tried with multiple div’s and classes that I have surrounding the images with display: inline-block and display: block to try and make the images in a horizontal line but nothing has been changing effectively.

    I know this may be hard to help me as I really can not make a codepen with the elements I have setup the way I do in my project as codepen doesn’t support php format. Thanks in advance for anyone that takes the time to help.

    Best regards,


    The PHP isn’t much use to us.

    We need to see a reduced case demo of the output HTML & CSS (you can use dummy images if necessary) if you want layout and styling answers.

    But gcyrillus is right…br tags are not mean to provide spacing between elements…that’s what margins & padding are for.

    If you need basic information on layout options I’d suggest you look at the inline-block and`float’ sections at


    Wow not sure why I even had the break there, sorry about that – removing the break there made the css look flawlessly as I wanted. I usually have no problem styling images and using in the inline-block style on my projects but the break there threw me off guard I suppose. Thank you guys for your help!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.