Ionic 3 ion-list horizontal - want to show a list ion-list horizontal

妖精的绣舞 提交于 2019-12-04 22:11:41

问题


I want to use Ionic 3 ion-list (or whatever works in Ionic 3) to show a horizontal list instead of the typical vertical list.

Looking for a solution without a lot of css or hard to maintain code.

        <ion-content>

          <ion-list >
            <ion-item *ngFor="let data of dataArray"  (click)="dataDetail(data)">
              <ion-thumbnail item-left>
                <img src="https://data.url.com/{{data.path}}{{data.photoName}}"/>
              </ion-thumbnail>
              <h2>{{data.name}}</h2>
              <p>{{data.details}}</p>
            </ion-item>
          </ion-list>

        </ion-content>

Any help is really appreciated.

Thanks Phil


回答1:


You can do it in this way. This works for me.

HTML

<ion-grid>
<ion-row>
  <ion-col col-33 *ngFor="let post of list">
 <div class="card card-1" (click)="ondemand_details(post.product_final_categories_id)">
   <img src="{{post.product_final_categories_icon}}">
    <p style="font-size: 9px;">{{post.product_final_categories_name}}</p>
   </div>
   </ion-col>
</ion-row>

And SCSS is:

img1 {
border: 2px solid #BA55D3;
border-radius: 50%;
padding: 5px;
width: 50px;
background-color:#4B0082;
box-shadow: 1px 1px 1px 1px yellow;
}
.card {
 background: #1E90FF;
 border-radius: 50%;
 display: inline-block;
 height: 50px;
 border: 1px solid #fff;
 padding: 7px;
 margin: 1rem;
 position: relative;
 width: 50px;
 }
.card-1 {
 box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
 transition: all 0.3s cubic-bezier(.25,.8,.25,1);
  }
 .card-1:hover {
 box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
  }

You can change the code according to your needs. If you face any problem please let me Known.

Hope this will help You.

Update horizental scroll Html:

 <ion-content padding>
<ion-item>

   <ion-scroll scrollX style="height:100px;">
  <div class="scroll-item">
  <ion-col col-33 *ngFor="let post of list">
 <div class="card card-1" (click)="ondemand_details(post.product_final_categories_id)">

   <img src="{{post.product_final_categories_icon}}">
    <p style="font-size: 9px;">{{post.product_final_categories_name}}</p>
   </div>
    </ion-col>
   </div>
   </ion-scroll>

</ion-item>
</ion-content>

Add SCSS:`

ion-scroll[scrollX] {
white-space: nowrap;
.scroll-item {
display: inline-block;
}}

I have tested it in my project, and it works fine. it will show output something like this.

I hope this will help you.



来源:https://stackoverflow.com/questions/45993221/ionic-3-ion-list-horizontal-want-to-show-a-list-ion-list-horizontal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!