【问题标题】:ng2-smart-table, align textng2-smart-table,对齐文本
【发布时间】:2018-09-21 16:31:53
【问题描述】:

我们如何在 ng2-smart-table 中将文本右对齐?

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    还有另一种方法,只使用 css

    将所有列向右移动:

    :host /deep/ ng2-smart-table tbody > tr > td{ text-align: right; }

    将所有标题向右移动:

    :host /deep/ ng2-smart-table thead th{ text-align: center; }

    将所有输入过滤器向右移动:

    :host /deep/ ng2-smart-table thead input-filter input{ text-align: center; }

    等等

    【讨论】:

    • 这个对我有用,我只需要使用:host ::ng-deep 而不是:host /deep/。谢谢。
    【解决方案2】:

    试试这个代码,它对我有用。

    this.settings.columns["title"] = { "title": this.settings.columns["title"].title, type:'html',valuePrepareFunction: function(value){
         return '<div class="customformat"> ' + value + ' </div>' 
    }};
    

    CSS

     :host /deep/ .customformat{ text-align: right; } 

    【讨论】:

    • 我使用了 return '
      ' + value + '
      ' 并且可以正常工作,谢谢您的回答,
    猜你喜欢
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    • 2019-01-08
    • 2020-01-03
    • 2019-04-17
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    相关资源
    最近更新 更多