我在一个5角的应用程序中有一个数据集:
<clr-datagrid>
<clr-dg-column>a</clr-dg-column>
<clr-dg-column>b</clr-dg-column>
<clr-dg-column>b</clr-dg-column>
<clr-dg-column>b</clr-dg-column>
<clr-dg-row>
<clr-dg-cell>1</clr-dg-cell>
<clr-dg-cell>2</clr-dg-cell>
<clr-dg-cell>3</clr-dg-cell>
<clr-dg-cell>4</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>在移动显示器上,这个表比屏幕宽,如何设置列的宽度,使其缩小。
编辑:我想要做的是重新创建这个记分表:https://boardgamegeek.com/image/3360178/clans-caledonia
我相信这应该是有可能创造一些接近它的输入到移动设备上。
发布于 2018-02-21 17:23:12
可以使用列上的css类设置列宽度。
<clr-datagrid>
<clr-dg-column class="width1">a</clr-dg-column>
<clr-dg-column class="width2">b</clr-dg-column>
<clr-dg-column class="width3">b</clr-dg-column>
<clr-dg-column>b</clr-dg-column>
<clr-dg-row *ngFor="let i of [1,2,3,4,5]">
<clr-dg-cell >1</clr-dg-cell>
<clr-dg-cell >2</clr-dg-cell>
<clr-dg-cell >3</clr-dg-cell>
<clr-dg-cell>4</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>CSS
.width1 {
width: 15%;
}
.width2 {
width: 25%;
}
.width3 {
width: 35%;
}Update在查看了StackBlitz之后,我突然想到,也许您可以使用一个简单的表。重写默认输入样式
td > input {
width: 1.5rem;
min-width: 1.5rem;
}并使用标准表元素
<table class="table">
<thead>
<tr>
<th></th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of [1,2,3,4,5,6]">
<td>Type {{item}}</td>
<td><input type="number"></td>
<td><input type="number"></td>
<td><input type="number"></td>
<td><input type="number"></td>
</tr>
</tbody>
</table>看起来它会在窄宽的视口上倒塌。
下面是修改后的StackBlitz:https://stackblitz.com/edit/angular-dbzvmg
发布于 2018-02-22 09:30:04
这似乎是可行的,尽管必须向所有列添加类,而所有单元格的类似乎都不太理想。
<clr-datagrid>
<clr-dg-column class="width">a</clr-dg-column>
<clr-dg-column class="width">b</clr-dg-column>
<clr-dg-column class="width">b</clr-dg-column>
<clr-dg-column class="width">b</clr-dg-column>
<clr-dg-row *ngFor="let i of [1,2,3,4,5]">
<clr-dg-cell class="width">1</clr-dg-cell>
<clr-dg-cell class="width">2</clr-dg-cell>
<clr-dg-cell class="width">3</clr-dg-cell>
<clr-dg-cell class="width">4</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>风格
.width {
width: 25%;
min-width: 20%;
}https://stackoverflow.com/questions/48881029
复制相似问题