首页 > 解决方案 > 回答问题时如何使用 [style.border] 更改边框样式?

问题描述

回答问题后,我无法将边框样式从 $vivid-blue 更改为 $medium-gray。这是我的代码:

<section id="question" [style.border]="!answer ? 'unanswered': 'answered'">

在 SCSS 中我有

.unanswered {
  border: 2px solid $vivid-blue !important;
}

.answered {
  border: 2px solid $medium-gray !important;
}

标签: angular

解决方案


这个:

<section id="question" [ngClass]="!answer ? 'unanswered': 'answered'">

或这个:

<section id="question" [style.border]="!answer ? 'border: 2px solid blue !important': 'border: 2px solid gray !important'">

推荐阅读