首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自定义组件内的离子项边框

自定义组件内的离子项边框
EN

Stack Overflow用户
提问于 2018-09-29 04:05:19
回答 1查看 335关注 0票数 3

我有如下所示的标记。

代码语言:javascript
复制
<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>

问题是,对于我的自定义组件中的离子项,没有绘制标准的底部边框。因为在dom中,它们在自定义组件中。我怎样才能返回底部的边框?

https://stackblitz.com/edit/ionic-7a3ai5?file=app%2Fapp.module.ts。例如,请参见home组件

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-29 09:06:45

似乎问题在于这些风格规则:

代码语言:javascript
复制
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一样)。

工作演示

代码语言:javascript
复制
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;
    }
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52565006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档