[英]Creating custom arrow in Angular Material sort header
I am creating Angular 5 project and I wanted to create custom sort icon in sort header to achieve this effect https://fontawesome.com/icons/caret-up?style=solid . 我正在创建Angular 5项目,我想在排序标题中创建自定义排序图标以实现此效果https://fontawesome.com/icons/caret-up?style=solid 。 I don't want to have this default arrow.
我不想使用此默认箭头。
I tried to change css style, but it seems not to work. 我试图更改CSS样式,但似乎不起作用。 Or maybe is there any way to replace this icon by custom using JS?
或者也许有什么方法可以使用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;
}
}
Thank for any suggestions. 感谢您的任何建议。
Edit. 编辑。
If someone has this problem, I solved it by adding custom directive to mat-sort-header element. 如果有人遇到此问题,我可以通过向mat-sort-header元素添加自定义指令来解决。 I also passed to directive the sort direction (ASC or DESC).
我还将指令传递给排序方向(ASC或DESC)。 Finally based on the direction I customized my sort icon using pure CSS.
最后,根据指导,我使用纯CSS自定义了排序图标。
see if this help you 看看这是否对您有帮助
.triangle { overflow: hidden; position: relative; margin: 2em auto; border-radius: 20%; transform: translateY(50%) rotate(30deg) skewY(30deg) scaleX(.866); width: 5em; height: 5em; } .triangle:before { border-radius: 20% 20% 20% 53%; transform: scaleX(1.155) skewY(-30deg) rotate(-30deg) translateY(-42.3%) skewX(30deg) scaleY(.866) translateX(-24%); position: absolute; background: #ccc; pointer-events: auto; content: ''; width: 5em; height: 5em; } .triangle:after { border-radius: 20% 20% 53% 20%; transform: scaleX(1.155) skewY(-30deg) rotate(-30deg) translateY(-42.3%) skewX(-30deg) scaleY(.866) translateX(24%); position: absolute; background: #ccc; pointer-events: auto; content: ''; width: 5em; height: 5em; }
<div class="triangle"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.