0

I'm trying to expand a DIV in a set of given DIVs for an image gallery, the issue I get is when I expend the specific DIV all the next ones get affected and move their positions which lets a big blank space that I don't want.

I tried the following CSS properties on the specific DIVs and none of them worked out so far :

height: 250px;
margin-bottom: 100px;

The css :

.thumb{
  float:left;
  margin:5px;
}

#gallery{
  width:850px;
}

The html :

<html>
    <head>
        <title>asd</title>
    </head>
    <body>
        <div id="gallery">
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=0">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=100">
            </div>
            <div class="thumb" style="height:250px;"> <!-- specific DIV to expand vertically !-->
                <img src="https://picsum.photos/155/155?image=200">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=350">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=400">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=500">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=600">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=700">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=800">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=900">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=950">
            </div>
            <div class="thumb">
                <img src="https://picsum.photos/155/155?image=990">
            </div>
        </div>
    </body>
</html>

The result I'm getting : enter image description here

The end result I want : enter image description here

I made the fiddle so you can better see what's happening : https://jsfiddle.net/537ayfwc/

I found a workaround by adding an invisible DIV that would act as a seperating line after every 5 pics but I'm trying to find a way to do without it as it adds more constraints to the future javascript animations I would like to perform on the whole gallery.

tcj
  • 1,645
  • 4
  • 13
  • 21

1 Answers1

1

Not sure if this is what you're looking for.

.thumb{
  float:left;
  margin:5px;
}

#gallery{
  width:850px;
  display: flex;
  flex-wrap: wrap;
}
donpsabance
  • 358
  • 3
  • 9