html - 在带有 Angular 条件类的 HTML 表格上设置边框在 Safari 上不起作用
问题描述
我试图让一个简单的 HTML 表格的一列感觉像是被选中的,只要用户使用 angular 点击一个元素,就给它一个边框:
app.component.ts :
import { Component } from '@angular/core' ;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
selectionArray = [false, false, false];
changeSelection(index: number): void {
this.selectionArray = this.selectionArray.map(() => false);
this.selectionArray[index] = true;
}
}
app.component.html :
<table border="1px" cellspacing="0">
<colgroup>
<col [class.selected]="selectionArray[0] === true">
<col [class.selected]="selectionArray[1] === true">
<col [class.selected]="selectionArray[2] === true">
</colgroup>
<thead>
<tr>
<th (click)="changeSelection(0)">Firstname</th>
<th (click)="changeSelection(1)">Lastname</th>
<th (click)="changeSelection(2)">Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</tbody>
</table>
app.component.css :
table {
border-collapse: collapse;
}
.selected {
border: 2px double yellowgreen;
}
上面的示例是使用 angular cli 7 生成和构建的,可以在 Chrome、Firefox 和 Edge 上完美运行。但是在 Safari (12) 上有一些奇怪的行为。首先,如果我将 .selected 类的边框更改为 1px,它根本不会在列周围绘制边框。但即使忽略这一点,只有第一次选择一列时,它才会有边框,Safari 会忽略其他点击,除非我以某种方式强制 Safari 调整窗口大小(通过缩小/缩小、更改开发者控制台的大小、调整大小手动窗口等)。
有什么我可以做的吗?
解决方案
推荐阅读
- python - AttributeError:模块 'cupy' 没有属性 'array'
- solr - 由于 timeAllowed 参数,识别 SOLR 返回空结果的方法?
- dart - List.sort 返回 null
- python - 如何解决python中的“中断代码”问题?
- python - 熊猫数据框为每日数据提供每周平均值
- javascript - JavaScript 数组过滤器返回未定义
- php - 我遇到了这个短代码插件的问题。警告:非法字符串偏移“标题”
- sql - Postgresql 复制槽错误 postgresql
- python - 使用 blob 链接下载数据
- java - 检查字符串数字数组是否包含符号