Angular 5 display *ngfor horizontally

前端 未结 3 1149
后悔当初
后悔当初 2021-01-16 07:36

i\'m building my first angular app using latest version and i need some help to display some informations in a specific position.

app.component.ts:

相关标签:
3条回答
  • 2021-01-16 08:18

    I don't know if you still need this, but just wrap your ngFor in a row div.

    <div class="row">
      <div *ngFor="let item of itemList">
        <span class="ml-2 badge badge-pill badge-primary"> {{item?.name}} </span>
      </div>
    </div>

    Here's an example of what that might look like.

    0 讨论(0)
  • 2021-01-16 08:25

    app.component.html:

        <div class="footer">
          <div class="row">
            <div class="col-sm-12 links" *ngFor="let social of socials">
        <div style="float:left;height:50px;"  [ngStyle]="{'width': 'calc(100% /' + socials.length + ')'}">
              <a href={{social.link}} target="_blank">
                <i class={{social.icon}} aria-hidden="true"></i>
                <span>{{social.name}}</span>
              </a>
            </div>
          </div>
        </div>
     </div>
    

    Link: https://stackblitz.com/edit/angular-zd69fh?file=app/app.component.html

    0 讨论(0)
  • 2021-01-16 08:32

    You could use the package Angular Flex Layout. You just have to use the row layout.

    <div fxLayout="row">
        <div *ngFor...></div>
    </div>
    

    Here is a link to the @angular/flex-layout library.

    And a demo here

    0 讨论(0)
提交回复
热议问题