将箭头放在已排序表的标题右侧。

huangapple go评论76阅读模式
英文:

How to place the arrow to the right of the header of a sorted table?

问题

You can move the arrow to the right side of the header element by changing the host style in the directive code. Here's the updated code:

@Directive({
  selector: 'th[sortable]',
  standalone: true,
  host: {
    '[class.bi-caret-down-fill]': 'direction === "asc"',
    '[class.bi-caret-up-fill]': 'direction === "desc"',
    '[(style.padding-left)]': 'direction === "asc" ? "0" : null',
    '[(style.padding-right)]': 'direction === "desc" ? "0" : null',
    '(click)': 'rotate()',
  },
})

This code adds padding-left and padding-right styles to adjust the position of the arrow to the right side of the header when the sorting direction is "desc."

英文:

I have a table and I want to add the sort option to all table headers, so I used the bootstrap exemple for my purpose.

The only problem in this example is the position of the arrow which is on the left side and I want it on the right side of the header element.

I checked the directive code and I found the code below :

@Directive({
  selector: 'th[sortable]',
  standalone: true,
  host: {
    '[class.bi-caret-down-fill]': 'direction === "asc"',
    '[class.bi-caret-up-fill]': 'direction === "desc"',
    '(click)': 'rotate()',
  },
})

How should I change the host style to move the arrow to the right side ?

答案1

得分: 1

index.html 中处理位置的 CSS 代码如下:

....
th[sortable].desc:before,
th[sortable].asc:before {
    content: '';
    float: left;
.....

float 属性改为 right 演示链接

英文:

On index.html css code which is handling the position is

....
th[sortable].desc:before,
th[sortable].asc:before {
    content: '';
    float: left;
.....

Change float property to right Working demo

huangapple
  • 本文由 发表于 2023年4月17日 17:10:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76033479.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定