【问题标题】:How to make button blur when button is disabled禁用按钮时如何使按钮模糊
【发布时间】:2021-01-27 13:52:33
【问题描述】:

当它被禁用时如何使按钮模糊。

有什么办法吗?

<button (click)="addRow()" class="add-row-btn" mat-button [disabled]="isDisabled"> Add Row</button>

【问题讨论】:

  • 模糊是什么意思?在 HTML 按钮标签中使用 disabled 将使按钮被禁用。
  • @funie200 blur 表示禁用前和禁用后按钮颜色相同。我想在禁用时将按钮颜色设为灰色
  • @ashish 我认为这可能是您可以使用 CSS 或条件类解决的问题 stackoverflow.com/questions/45635845/…

标签: html css angular angular8


【解决方案1】:

您可以在按钮类上使用 :disabled 选择器,如下所示:

HTML

 <button class="add-row-btn" disabled="disabled" onclick="addRow()"> Add Row</button>

CSS

.add-row-btn:disabled {
  background-color:orangered;
}

codepenhttps://codepen.io/ahamdan/pen/wvWKgqp

【讨论】:

    【解决方案2】:

    点击我!

    button:disabled {
       background: #222;
       color: #fff;
       font-weight: 900;
       padding: 15px 30px;
       border-radius: 5px;
       filter: blur(2px);
    }
    

    【讨论】:

    • 我怎样才能让按钮背景颜色变成灰色?只有背景,没有别的
    • 按钮:禁用{背景:#d2d2d2; } 就用这个
    【解决方案3】:

    您可以使用 css 实现此目的:

    button[disabled] {
      filter: blur(2px);
    }
    Enabled button:
    <button>Button</button>
    <hr/>
    Disabled button:
    <button disabled="disabled">Button</button>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      相关资源
      最近更新 更多