【发布时间】:2018-12-06 09:34:22
【问题描述】:
我正在创建 Angular 5 项目,我想在排序标题中创建自定义排序图标以实现此效果 https://fontawesome.com/icons/caret-up?style=solid。我不想有这个默认箭头。
我尝试更改 css 样式,但似乎不起作用。或者有没有办法通过自定义使用JS来替换这个图标?
::ng-deep {
.cdk-visually-hidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.mat-sort-header-stem {
background: none;
display: none !important;
}
.mat-sort-header-container {
position: relative;
}
.mat-sort-header-indicator {
transform: translateY(0px) !important;
}
.mat-sort-header-arrow {
position: absolute;
right: 20px;
transform: translateY(0%) !important;
}
}
感谢您的任何建议。
编辑。
如果有人遇到这个问题,我通过向 mat-sort-header 元素添加自定义指令来解决它。我还将排序方向(ASC 或 DESC)传递给指令。最后根据方向,我使用纯 CSS 自定义了排序图标。
【问题讨论】:
-
试试这个点击here mat-sort icon change like caret-up
标签: javascript css angular angular-material