【发布时间】:2018-02-24 10:30:22
【问题描述】:
我按条件嵌套input标签:
<td *ngFor="let cell of row.Persons">
<span cell.editable === true ">
<input type="number" [(ngModel)]="cell.PersonCount" autofocus />
</span>
<span *ngIf="cell.editable === false " (click)="toggle(cell)">
{{ cell.PersonCount ? cell.PersonCount : '-' }}
</span>
</td>
我尝试设置以下样式,但没有结果:
<input type="number" [(ngModel)]="cell.PersonCount"
style="display: inline; max-width: 100%; width: inherit; height:
inherit; box-sizing: border-box !important; overflow:hidden;
-moz-box-sizing: border-box !important;
-webkit-box-sizing: border-box !important; border: none;" autofocus />
我的问题是我怎样才能使单元格的大小保持不变,就像没有input 标签一样(就像第一张图片一样)?
我创建了an example at plunker,请看。
【问题讨论】:
-
检查输入的最小宽度。
-
@lexith 我应该为
min-width设置什么值? -
我可能会将宽度设置为 100%,将最小宽度设置为 0
-
@lexith 设置
min-width:0不会阻止调整大小。 -
Mhhhh,你能提供一个小的可重现的 plunkr 吗?因为我经常遇到这种行为,而且总是 minWidth 问题,所以我猜。
标签: html angular html-table tablecell