【问题标题】:Add a tick to button when selected in Angular 2 app在 Angular 2 应用程序中选择时为按钮添加一个勾号
【发布时间】:2021-07-23 14:08:19
【问题描述】:

我是Angular 2 的新手,我希望在选择时显示自定义按钮。对于问题,我有 2 个按钮作为答案,只允许选择一个(我已经完成了所有这些工作),但我想做的是在所选按钮值中添加一个勾号。

我知道这需要在 CSS 中完成,这很好,但我不知道该怎么做。

我尝试了以下方法,但似乎不起作用:

.md-fab.md-primary.md-grey-ajb-red-theme.md-button, .md-raised.md-primary.md-grey-ajb-red-theme.md-button
{
    font-family:'Glyphicons Halflings';
    content:"\e089";
}

以下是我想要的示例。当按钮未选择或未选择时,按钮应该只说“是”并且显然具有不同的颜色:

【问题讨论】:

    标签: html css angular


    【解决方案1】:

    试试这个:

    .md-fab.md-primary.md-grey-ajb-red-theme.md-button, .md-raised.md-primary.md-grey-ajb-red-theme.md-button
    {
        position: relative;
        text-align: center;
    }
    
    .md-fab.md-primary.md-grey-ajb-red-theme.md-button:before, .md-raised.md-primary.md-grey-ajb-red-theme.md-button:before
    {
        content:"\e089";
        display: block;
        font-family:'Glyphicons Halflings';
        font-size: 20px;
        position: absolute;
        top: 7px; // adjust as per your need
        left: 110px; // adjust as per your need
    }
    

    【讨论】:

    • 感谢您的回复,但它什么也没做,没有图像或任何东西
    • 请检查按钮是否生成伪元素。
    【解决方案2】:

    采用布尔变量将类设置为关闭并在按钮单击时呈现文本。在点击时调用一个方法来改变按钮文本。

    【讨论】:

      猜你喜欢
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 2017-03-20
      • 2021-03-13
      • 2013-07-20
      • 2019-09-23
      相关资源
      最近更新 更多