0

I have simple gallery like this:

<div class="gallery">

<div class="thumbnail">

    <img src="1.jpg">

</div>  

<div class="thumbnail">

    <img src="2.jpg">

</div>  

...

</div>  

How to auto-align thumnbails in row?

First thumbnails from the row should be align to the left and last from row to the right

Margin between align should be change dynamically.

Igor
  • 9
  • 2
  • possible duplicate of [CSS flexbox: difference between align-items and align-content](http://stackoverflow.com/questions/31250174/css-flexbox-difference-between-align-items-and-align-content) – klaar Aug 03 '15 at 11:57
  • See http://stackoverflow.com/questions/31250174/css-flexbox-difference-between-align-items-and-align-content, where `justify-content` should either be set to `space-between` or `space-around`. – klaar Aug 03 '15 at 11:58

2 Answers2

3

You can use display: flex on the outer box.
And use all the flex properties you need to display the inner boxes as you like.

.gallery{
    display: flex;
    flex-direction: row;
}

.thumbnail{
    flex: 0 0 100px;
    height: 100px;
    border: solid gray 3px;
}

Live example https://jsfiddle.net/m12xcxwy/

Complete tutorial on flexbox : https://css-tricks.com/snippets/css/a-guide-to-flexbox/

singe3
  • 2,065
  • 4
  • 30
  • 48
2

hi you can see if this is as per your desire

.gallery{
    display:block;
}
.thumbnail{
    display:inline-block;
    border:1px solid black;
    float:left;
    height:100px;
    width:100px;
}
Himesh Aadeshara
  • 2,114
  • 16
  • 26