简体   繁体   English

在离子之间添加自定义规则<ion-item>

[英]Add custom rule between ionic <ion-item>

I am trying to put a custom horizontal rule between the <ion-item> s in my list.我正在尝试在我的列表中的<ion-item>之间放置一个自定义水平规则。

My CSS works fine with <ion-list> except that <ion-list> adds its own rules which I don't want.我的 CSS 与<ion-list>一起工作得很好,只是<ion-list>添加了我不想要的自己的规则。 I just want my custom rule.我只想要我的自定义规则。

If I try using <ion-list no-lines> (to remove the rules that <ion-list> adds automatically my CSS doesn't work any more, and I don't get my custom rules.如果我尝试使用<ion-list no-lines> (删除<ion-list>自动添加的规则,我的 CSS 将不再起作用,并且我没有得到我的自定义规则。

My CSS is:我的 CSS 是:

.my-item {
  border-style:solid;
  border-bottom-width: 11px;
  border-bottom-color: black;
}

My HTML is:我的 HTML 是:

<ion-list>
  <ion-item class="my-item>Something</ion-item>
  <ion-item class="my-item>Something Else</ion-item>
</ion-list>

ADDED MY REAL CODE添加我的真实代码

In case this helps here is the actual code I am using:如果这有帮助,这里是我正在使用的实际代码:

 page-my-plans { } .pu-my-plans-plus-circle { display: block; //border: 2px solid white; background-color: $pu-orange; border-radius: 50%; height: 38px; width: 38px; } .pu-my-plans-plus-circle span { font-size: 38px; font-weight: 100; color: white; position: absolute; top: -7px; left: 8.5px; } .pu-plan-addButton { font-size: 30px; margin-right: 14px; margin-top:-2px; } .pu-section-list-item{ color: black; font-weight:$pu-item-font-weight; font-size:$pu-item-font-size; padding-left:20px; padding-right:0px; margin-bottom: 4px; } .item{ background: transparent !important; } // THEMING CSS // =========== // .pu-my-plans-background { background-image: url("../assets/img/PU_Light_BG_1.png"); background-size: cover !important; } .pu-my-plans-item { border: none; border-bottom: 11px solid black; } .pu-my-plans-plan-date { color: black; //$pu-orange; font-size: 11px; font-weight: 200; }
 <ion-content class="pu-my-plans-background"> <div *ngIf="hasPlans"> <ion-list no-lines class="pu-item-list"> <!--<ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">--> <ion-item-sliding *ngFor="let plan of plans; let i = index" > <ion-item class="pu-section-list-item pu-my-plans-item" (click)="editPlan(plan.id, plan.rev, plan.title, i)"> {{ plan.title }} <br> <span class="pu-my-plans-plan-date">{{ plan.updated}}</span> <button *ngIf="plan.important" ion-button clear item-right> <ion-icon name="ios-alert-outline"></ion-icon> </button> </ion-item> <ion-item-options side="right"> <button ion-button color="danger" (click)="deletePlan(plan.id, plan.rev)"> <ion-icon name="delete"></ion-icon> Delete </button> </ion-item-options> <div class="xxx">SOME TEXT</div> </ion-item-sliding> <!--</ion-item-group>--> </ion-list> </div> </ion-content>

With this code my attempts to get a border rule fail.使用此代码,我尝试获得边界规则失败。 If I add no-lines to <ion-list> my border works but I also get the lines that <ion-list> produces.如果我向<ion-list>添加no-lines我的边框可以工作,但我也会得到<ion-list>产生的线条。

This is what it looks like with the code above:这是上面代码的样子:

在此处输入图片说明

If I take away no-rules it looks like this:如果我去掉no-rules它看起来像这样:

在此处输入图片说明

There is a rule at the bottom of the list and the last item does not have the border I am trying to apply.列表底部有一条规则,最后一项没有我要应用的边框。

Just preface your own border with a reset.只需在您自己的边框之前进行重置即可。

.my-item {
    border: none;
    border-bottom: 11px solid black;
}

Edit:编辑:

Ionic 2's ios styles also contain a rule, specific to the last child and it's border, which is what needs to be overridden here. Ionic 2 的 ios 样式还包含一个规则,特定于最后一个孩子及其边框,这是这里需要覆盖的内容。

.list-ios>.item-block:last-child, .list-ios>.item-wrapper:last-child .item-block { 
    border-bottom: .55px solid #c8c7cc; 
}

I can help you, but i need to acces source code.我可以帮你,但我需要访问源代码。 http://view.ionic.io/ http://view.ionic.io/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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