Angularjs 如何将ng表格标题居中对齐?
全部,, 我使用ng表格作为网格。我使用下面的代码片段来设置列Angularjs 如何将ng表格标题居中对齐?,angularjs,ngtable,Angularjs,Ngtable,全部,, 我使用ng表格作为网格。我使用下面的代码片段来设置列 {{people.accessID}} jsiddle您可以使用header class属性为您猜到的头设置类 <td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center" header-class="text-center">{{people.accessID}}</td> {{peo
{{people.accessID}}
jsiddle您可以使用
header class
属性为您猜到的头设置类
<td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center" header-class="text-center">{{people.accessID}}</td>
{{people.accessID}
由@OpenUserX03提交的答案几乎完美无瑕,只是您必须将类名用单引号括起来,如下所示:
<td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center" header-class="'text-center'">{{people.accessID}}</td>
{{people.accessID}
我以前也遇到过同样的问题:如何对齐左侧ng表格标题。
在ng表的文档中,它没有说明任何内容,也没有提到示例
你有两种方法可以做到这一点-快速和更“专业”
快捷方式:
根据您使用的css文件打开文件ng table/dist/ng-table.css和ng table.min.css。
在第一行,它管理标题
.ng-table th {
text-align: center;/*just change that parameter to left/right*/
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
“专业”方式:创建自定义样式并将其添加到您的网站css文件中,如下所示:
.table thead th {
text-align: left;/*change that parameter to left/right*/
}
希望有帮助,祝你好运。修复ngTable 对于那些一年后看到这一点的人。上述解决方案对我都不起作用。我将其添加到自定义css文件中:
.ng-table th {
text-align: center !important;
}
将内容放在标题的中心位置(参见图片)
来自此:
对此:
对于仍然有这个问题的任何人,也是OP,因为他还没有接受答案,我就是这样做的。在您的css中(any.css)
文本对齐中心不工作?@Gokul:您找到程序的解决方案了吗?他特别询问使用ng表格的列标题。您的示例之所以有效,是因为它没有使用ng-table.add。头不在JSFIDDLE中居中。这可能取决于您正在使用的库的版本。我们拥有的版本(奇怪的是没有包含在JS中)不支持
headerClass
的表达式形式@OpenUserX03的答案对我来说很有用。对我来说,有效的currect语法是:header class=“'text center'”,而不是:header class=“text center”
.ng-table th {
text-align: center !important;
}
table[ng-table] th {
text-align: left;
border-top: none;
}