【发布时间】:2019-11-30 12:30:25
【问题描述】:
今天我在 HTML 组件中的关闭按钮遇到了一个奇怪的问题。即当我打开组件(客户的详细信息按钮)时,开头的关闭按钮被蓝色边框包围。单击组件上的任意位置后,边框消失。 如下图所示的问题:
我试图在我的 CSS 类中设置选项,如大纲:无,但它没有带来理想的结果。此外,当我将复制相同的组件时:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"(click)="onClose()">
<span aria-hidden="true">×</span>
</button>
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
只有第一个关闭按钮有蓝色边框。
客户详细信息.coponent.html
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"(click)="onClose()">
<span aria-hidden="true">×</span>
</button>
</div>
<h4 class="modal-title w-100 font-weight-bold">Customer details:</h4>
<div *ngIf="(this.customer$ | async) as customer; else loading">
{{customer.name}}
</div>
<div *ngIf="(this.customer$ | async) as customer; else loading">
{{customer.email}}
</div>
<div *ngIf="(this.customer$ | async) as customer; else loading">
{{customer.phoneNumber}}
</div>
<ng-template #loading>
Loading stuff in ngIf...
</ng-template>
我想要实现的只是在组件打开后不出现这个蓝色边框。我不确定这是否是我的浏览器的问题,但目前我正在使用谷歌浏览器。感谢您对我应该做些什么来达到理想效果的建议。
【问题讨论】:
-
将css属性
outline:none;设置为“关闭”按钮,应该可以解决您的问题。 -
当您使用
buttonhtml 标记时尤其会发生这种情况,如果您想在不覆盖默认按钮行为的情况下移除蓝色边框,请使用不同的标记,例如可点击的div跨度> -
button:focus {outline:0;} 将解决此问题
-
非常感谢您的快速回复。我的 CSS 声明有一个错误,这就是它无法正常工作的原因。再次感谢您提供即时提示。