Reputation: 511
I am using Angular 7
I have used image thumbnail class of bootstrap it is aligning vertically, I want to align horizontally.
.thumbnail
{
text-align: center;
float: left;
}
.row
{
text-align: center;
}
Following is my code:
<div class= "row">
<div class = "col-xs-12">
<button class="btn btn-success">New Recipe</button>
</div>
<hr>
<div class = "col-md-12" >
<a href="#" class="thumbnail" *ngFor="let recipe of recipes">
<img src = "{{ recipe.imagePath }}" alt="{{ recipe.name }}" class =
"img-responsive" class="img-thumbnail">
<h4 class = "caption">{{ recipe.name }}</h4>
<p class = "caption">{{ recipe.description }}</p>
</a>
<app-recepie-item></app-recepie-item>
</div>
</div>
Have created 2 objects
recipes: Recipe [] = [ new Recipe('My Sample Recipe', 'This is my first
recipe', 'image url'),
new Recipe('Potato Recipe', 'This an actual Potato
Recipe', 'http://coastguard.dodlive.mil/files/2014/04/unnamed-2-
560x281.jpg')];
Output seems like this.
Thumbnails are displaying vertically.
I want to display horizontally.
Upvotes: 1
Views: 449
Reputation: 1778
I think you no need to write more css if you using grid property of bootstrap for alignment.
HTML:
<div class="container">
<div class="row">
<div class = "col-xs-12">
<button class="btn btn-success">New Recipe</button>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-4 col-xs-4" *ngFor="let recipe of recipes">
<a href="#">
<img src={{recipe.url}} height="100" width="100">
<h4 class = "caption">{{ recipe.name }}</h4>
<p class = "caption">{{ recipe.desc }}</p>
</a>
</div>
</div>
</div>
TS:
recipes: any[] = [
{name:'product_name', desc: 'Description', url: 'http://www.movingimage.us/images/homepage/features/jhe_jim_kermit.jpg'},
{name:'product_name', desc: 'Description', url: 'http://www.movingimage.us/images/homepage/features/jhe_jim_kermit.jpg'},
{name:'product_name', desc: 'Description', url: 'http://wallpaper-gallery.net/images/image/image-8.jpg'}
];
Upvotes: 1