Css 在ng网格单元模板中换行文本?
我有一些文本显示如下:Css 在ng网格单元模板中换行文本?,css,angularjs,ng-grid,word-wrap,celltemplate,Css,Angularjs,Ng Grid,Word Wrap,Celltemplate,我有一些文本显示如下: columnDefs: [ field: "text", displayName: 'Text', width:'20%', cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><span ng-repeat = "text in COL_FIELD" ng-cell-text>{{text.name}}{{$last ? "" : ", "}}</span
columnDefs: [
field: "text", displayName: 'Text', width:'20%',
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><span ng-repeat = "text in COL_FIELD" ng-cell-text>{{text.name}}{{$last ? "" : ", "}}</span></div>'}
]
columnDefs:[
字段:“文本”,显示名称:“文本”,宽度:“20%”,
单元模板:{{text.name}{{$last?”:“,”}}}}
]
它基本上遍历我在.js文件中声明的“text”变量数组,并在单元格中显示内容。有没有一种方法可以将文本环绕在我提供的20%宽度上?我知道style=“white space:normal
可以进行文本包装,但我不知道如何将其与我上面的陈述结合起来。如果有人能帮忙,那就太好了
谢谢!您应该能够在单元格中输入所需的数据,然后使用以下CSS代码将允许在网格单元格中进行文本包装
/* CSS to allow text wrapping */
.ui-grid-viewport .ui-grid-cell-contents {
word-wrap: break-word;
white-space: normal !important;
}
.ui-grid-row, .ui-grid-cell {
height: auto !important;
}
.ui-grid-row div[role=row] {
display: flex ;
align-content: stretch;
}
/* End of CSS to allow text wrapping */
我不明白。请告诉我们您的变量是如何在js中声明的。ng网格中的宽度定义了列的宽度。因此,您希望列占据可用网格宽度的20%。它对单元格内容(我知道)没有任何作用,也就是说,导致它们换行。