It seems like a simple CSS fix can solve this:
.picture-container
{
display: flex;
justify-content: space-between;
}
.picture-container img {
height: 150px;
float: left;
}
You can maintain the same HTML structure by removing the height attribute from the img
tag:
<div class="picture-container" *ngFor="let picture of dataset">
<img src="{{picture.url}}" />
</div>
Quick suggestion:
When adjusting CSS
styles, you can use Chrome or Firefox's element inspection tool to modify the CSS rules in real-time until you achieve the desired look. Once satisfied, transfer those rules to your code for consistency.
Update 1 - Flexbox solution:
gallery {
padding: .5vw;
display: -ms-flexbox;
-ms-flex-wrap: wrap;
-ms-flex-direction: column;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
display: -webkit-box;
display: flex;
}
gallery item {
-webkit-box-flex: auto;
-ms-flex: auto;
flex: auto;
height: 150px;
margin: .5vw;
}
gallery item img {
height: 100%;
}
Corresponding HTML:
<gallery>
<item *ngFor="let picture of dataset">
<img src="{{picture.url}}" />
</item>
<gallery>