简体   繁体   中英

How to align elements in ionic 2 using ion-row and ion-col?

I'm trying to achieve a list similar to the one shown here: http://arunsfolio.com/wp-content/uploads/2015/04/list-petro.png

I'm not sure if I am missing something in sass.

This is the code:

 <ion-row>

    <ion-col width-40>
        <h4>Esso</h4>
        <p>Ungrester - 54</p>
        <p>84859 - munch</p>
    </ion-col>
    <ion-col width-40>
        <div class="priceStyle">
            <div class="priceChild">
                $123
            </div>

        </div>
    </ion-col>
    <ion-col width-10>
       <div>
        12KM
      </div>
    </ion-col>
</ion-row>


SCSS:
.priceStyle {
        background-color: lightblue;
        display: flex;
        flex-direction: column;

        width: 100px; 
        height: 50px; 
        border-radius: 2px;


    }

.priceChild {
        font-weight: bold;
        font-size: 1.5em;
        color: white;
        margin: 0;
        flex: 1;
        justify-content: flex-end;
        align-items: flex-end;
    }

My code isn't aligning the elements in the centre.

This is how it is displayed right now:

在此输入图像描述 Appreciate your help.

Thanks.

You can use the properties:

display: flex;
justify-content: center;

on the <ion-row> element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM