【问题标题】:how to place an icon badge on ionic?如何在离子上放置图标徽章?
【发布时间】:2020-10-11 01:19:27
【问题描述】:

如何使用 ionic 和 scss 设计带有通知徽章且没有编号的卡片

如下制作不带编号的徽章

我有以下 scss 但它没有响应

<ion-card class="ion-margin-top">
     <ion-badge color="danger">1</ion-badge>
     <ion-icon name="settings-outline"></ion-icon>
     <ion-card-content>
       <span class="contentText">Configuration</span>
     </ion-card-content>
</ion-card>

ion-card {
   background: #fff;
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
   margin: 0;
 
   ion-icon {
     width: 75%;
     margin-top: 16px;
     font-size: 5em;
   }
   ion-badge {
       position: absolute;
       top: 20px;
       right: 50px;
       }
}

【问题讨论】:

    标签: css ionic-framework sass badge ionicons


    【解决方案1】:

    添加到 ion-badge css

    z-index:100;
    

    这会将徽章带到图标前面..

    添加--color属性,它会改变文本的颜色,使其与背景颜色相同..

    --background可用于指定徽章的背景颜色。

    Reference Docs

    【讨论】:

    • 感谢您的推荐,但我想取消您的号码并将其作为没有号码的通知。
    • 没有编号的徽章
    • 那么我建议你在图标上添加一个静态图像。因为即使你删除了数字,徽章也可能不是一个完美的圆圈……参考这个w3schools.com/howto/howto_css_image_text.asp
    猜你喜欢
    • 2015-12-01
    • 1970-01-01
    • 2018-12-06
    • 2016-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多