avex
February 24, 2019, 12:10pm
1
For Ionic V4,
how do you remove end line of last child of ion-items using css?
No scripts please!
In this case, when advanceOpts is true, last item is Item4, else Item2.
In other cases, any one may be the last item, using CSS is quick and flexible, because browser optimize the render, that’s why people in stackoverflow ask for CSS solution.
Now, with Ionic V4 component, I have no idea to do such kind of easy thing.
<ion-button (click)="advanceOpts=!advanceOpts;">
<ion-list>
<ion-item>
<ion-label>Item1</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>Item2</ion-label>
<ion-toggle slot="end"></ion-toggle>
</ion-item>
<ion-item *ngIf="advanceOpts">
<ion-label>Item3</ion-label>
<ion-radio slot="end"></ion-radio>
</ion-item>
<ion-item *ngIf="advanceOpts">
<ion-label>Item4</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>
</ion-list>
Hello @avex
You can do that in the scss file of your page/component.
ion-item:last-child {
--border-width: 0 0 0 0 !important;
}
Based on :https://www.youtube.com/watch?v=_D1lCoYzivA
I hope it helps you
1 Like
parija
February 26, 2019, 9:54am
3
that worked for me. thanks
avex
February 27, 2019, 8:20am
4
no, that doesn’t help.
maybe it does matter with the content of ion-item. I miss ion-icon
<ion-item *ngIf="advanceOpts">
<ion-icon name="ios-pricetag" slot="start"></ion-icon>
<ion-label>Item4</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>
And I used css below before :
ion-item:last-child {
.item-inner {
border-bottom: 0px;
}
}
avex
March 1, 2019, 7:03pm
5
People who use slot in front of item, --inner-border-width can solve your problem.
ion-item:last-child {
--inner-border-width: 0;
}
15 Likes
I think this avoids CSS:
<ion-item lines="none">
...
</ion-item>
but maybe does not exactly address your issue.
3 Likes
MAY116
February 10, 2020, 10:39am
8
this is my solution , it works for me , i use ionic 4
<ion-list class="no-last-border">...</ion-list>
and in css i use below :
ion-list.no-last-border {
:last-child {
--border-style: none !important;
}
}```
3 Likes
eping
February 2, 2021, 4:04pm
12
Works on Ionic 5, thank you very much
why not use just <ion-item lines="none">......</ion-item>
Thankyou, for neat solution