When I'm trying add width by percentage, it's not working. It's showing like image per row.
Is there any way to fix the issue ?
Here is my HTML Code:
<ngx-masonry [options]="options" [ordered]="true">
<div ngxMasonryItem class="masonry-item" *ngFor="let item of gallery" [style.width.%]="[item.width]">
<a class="" href="/assets/images/gallery/{{item.image}}" data-fancybox="gallery">
<img src="/assets/images/gallery/{{item.image}}" class="img-fluid" alt="">
</a>
</div>
</ngx-masonry>
Ts Code:
public options: NgxMasonryOptions = {
itemSelector: '.masonry-item',
gutter: 10,
resize: true,
};
public gallery = [
{
'image' : 'image1.jpg',
'width' : '50%'
},
{
'image' : 'image2.jpg',
'width' : '25%'
},
{
'image' : 'image3.jpg',
'width' : '25%'
},
{
'image' : 'image4.jpg',
'width' : '50%'
},
{
'image' : 'image5.jpg',
'width' : '50%'
}
]
I have updated my code to,
Ts
public options: NgxMasonryOptions = {
itemSelector: '.masonry-item',
gutter: 0,
resize: true,
};
public gallery = [
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 50,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
{
'image' : 'https://images.unsplash.com/photo-1578133630261-a79a92922335?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&q=80&w=400',
'width' : 25,
},
]
HTML
<ngx-masonry [options]="options" [ordered]="true">
<div ngxMasonryItem class="masonry-item ratio ratio-1x1" *ngFor="let item of gallery" [style.width.%]="[item.width]">
<img src="{{ item.image }}" style="width: 100%;">
</div>
</ngx-masonry>
It's not working properly ..........................................................................
Thanks.