Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

flexbox breaking line instead of printing in a row

I have a normal, easy flexbox layout. I try to show two elements per row. There is enough width for 2 elements. But strangely, every element gets one whole row. I don’t know why. Here is my code:

gallery.html:

<div class="container" *ngFor="let imageOrFile of imagesAndFiles">
  <div class="image">
    <dispo-einsatz-dokumente-gallery-image-item
      [image]="imageOrFile"
    ></dispo-einsatz-dokumente-gallery-image-item>
  </div>
</div>

gallery.scss:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

.image {
  width: 40%;
  height: 200px;
}

And the child component html:

<p>{{ image.name }}</p>

This is the result:

enter image description here

Why is it like this? How do I get my two elements in one row?

>Solution :

move the for loop to the div.image element, container class element is being rendered multiple times, you want to render the container class element once with multiple image class elements

<div class="container">
  <div class="image" *ngFor="let imageOrFile of imagesAndFiles">
    <dispo-einsatz-dokumente-gallery-image-item
      [image]="imageOrFile"
    ></dispo-einsatz-dokumente-gallery-image-item>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading