自定义组件内的 ion-item 边框
ion-item border inside custom component
我有如下所示的标记。
<ion-item-group>
<ion-item>First</ion-item>
<ion-item>Second</ion-item>
<ion-item>Third</ion-item>
</ion-item-group>
<ion-item-group>
<custom-component></custom-component>
<custom-component></custom-component>
</ion-item-group>
#Custom component markup#
<ion-item>Test<ion-item>
问题是对于我的自定义组件中的 ion-item,没有绘制标准底部边框。因为在 dom 中它们位于自定义组件内。我怎样才能return底部边框?
https://stackblitz.com/edit/ionic-7a3ai5?file=app%2Fapp.module.ts。例如,请参阅 home 组件
问题似乎出在这些样式规则上:
ion-item-group .item-md .item-wrapper:last-child .item-inner,
ion-item-group .item-md:last-child .item-inner {
border: 0;
}
ion-item-group .item-ios:last-child .item-inner,
ion-item-group .item-wrapper:last-child .item-ios .item-inner {
border: 0;
}
应用它们是因为每个 custom-component
只包含一个项目,所以每个项目都是其父项的最后一个子项。
解决此问题的一种方法是手动将 Ionic 默认边框应用于自定义组件中的每个项目(最后 custom-component
中的项目除外,就像 Ionic 所做的那样)。
Working demo
custom-component {
/* ------- */
/* Android */
/* ------- */
/* Add the border to each item */
.item-md.item-block .item-inner,
ion-item-group .item-md .item-wrapper:last-child .item-inner,
ion-item-group .item-md:last-child .item-inner {
border-bottom: 1px solid #dedede;
}
/* Remove the border from the last custom component item */
&:last-child {
.item-md .item-wrapper:last-child .item-inner,
.item-md:last-child .item-inner {
border: 0;
}
}
/* --- */
/* iOS */
/* --- */
/* Add the border to each item */
.item-ios.item-block .item-inner,
ion-item-group .item-ios:last-child .item-inner,
ion-item-group .item-wrapper:last-child .item-ios .item-inner {
border-bottom: .55px solid #c8c7cc;
}
/* Remove the border from the last custom component item */
&:last-child {
.item-ios:last-child .item-inner,
.item-wrapper:last-child .item-ios .item-inner {
border: 0;
}
}
}
我有如下所示的标记。
<ion-item-group>
<ion-item>First</ion-item>
<ion-item>Second</ion-item>
<ion-item>Third</ion-item>
</ion-item-group>
<ion-item-group>
<custom-component></custom-component>
<custom-component></custom-component>
</ion-item-group>
#Custom component markup#
<ion-item>Test<ion-item>
问题是对于我的自定义组件中的 ion-item,没有绘制标准底部边框。因为在 dom 中它们位于自定义组件内。我怎样才能return底部边框?
https://stackblitz.com/edit/ionic-7a3ai5?file=app%2Fapp.module.ts。例如,请参阅 home 组件
问题似乎出在这些样式规则上:
ion-item-group .item-md .item-wrapper:last-child .item-inner,
ion-item-group .item-md:last-child .item-inner {
border: 0;
}
ion-item-group .item-ios:last-child .item-inner,
ion-item-group .item-wrapper:last-child .item-ios .item-inner {
border: 0;
}
应用它们是因为每个 custom-component
只包含一个项目,所以每个项目都是其父项的最后一个子项。
解决此问题的一种方法是手动将 Ionic 默认边框应用于自定义组件中的每个项目(最后 custom-component
中的项目除外,就像 Ionic 所做的那样)。
Working demo
custom-component {
/* ------- */
/* Android */
/* ------- */
/* Add the border to each item */
.item-md.item-block .item-inner,
ion-item-group .item-md .item-wrapper:last-child .item-inner,
ion-item-group .item-md:last-child .item-inner {
border-bottom: 1px solid #dedede;
}
/* Remove the border from the last custom component item */
&:last-child {
.item-md .item-wrapper:last-child .item-inner,
.item-md:last-child .item-inner {
border: 0;
}
}
/* --- */
/* iOS */
/* --- */
/* Add the border to each item */
.item-ios.item-block .item-inner,
ion-item-group .item-ios:last-child .item-inner,
ion-item-group .item-wrapper:last-child .item-ios .item-inner {
border-bottom: .55px solid #c8c7cc;
}
/* Remove the border from the last custom component item */
&:last-child {
.item-ios:last-child .item-inner,
.item-wrapper:last-child .item-ios .item-inner {
border: 0;
}
}
}