Mis*_*ify 6 css blazor mudblazor
我有一个包含 5 列的表,其中一列包含一些非常长的用户 ID(没有空格)。它不是将文本剪掉,而是扩展该列以容纳所有内容,将其他列推到右侧并导致出现滚动条。
我已经研究了几个小时,试图找出如何修复宽度并阻止其溢出。我尝试将table-layout属性设置为fixed元素MudTable,并尝试使用width:20%; word-wrap:break-word; white-space:nowrap; overflow: hidden; text-overflow: ellipsis;我能想到的任何东西的变体,例如col MudTd等等,但没有任何效果,甚至没有任何效果。
该文档似乎根本没有涵盖溢出,这令人沮丧。设置col宽度效果很好,直到数据变得太长,并且设置max-width也没有帮助。
这似乎是 MudTable 中应该满足的问题,任何人都可以告诉我我做错了什么,或者建议修复吗?
这是我的桌子:
<MudTable id="results-table" ServerData="@(new Func<TableState, Task<TableData<HiHi1User>>>(LoadUsers))" RowsPerPage="50" FixedHeader=@_tableFixedHeader FixedFooter=@_tableFixedFooter
Style="table-layout:fixed" Height=@_tableFixedHeight Hover="true" Striped="true" Breakpoint="Breakpoint.Sm" Loading="@_loading" LoadingProgressColor="Color.Primary">
<ColGroup>
<col style="width:20%;" />
<col style="width:20%;" />
<col style="width:20%;" />
<col style="width:20%;" />
<col style="width:20%;" />
</ColGroup>
<HeaderContent>
<MudTh id="user-id-hdr">User ID</MudTh>
<MudTh id="group-id-hdr">Group ID</MudTh>
<MudTh id="current-versions-hdr">Current Version</MudTh>
<MudTh id="max-versions-hdr">Max Version</MudTh>
<MudTh id="can-alter-gnf-hdr">Can Alter Night Forwarding Status</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd id="user-id-val" DataLabel=@nameof(context.UserId)>@context.UserId</MudTd>
<MudTd id="group-id-val" DataLabel=@nameof(context.GroupId)>@context.GroupId</MudTd>
<MudTd id="current-versions-val" DataLabel=@nameof(context.CurrentVersion)>@context.CurrentVersion</MudTd>
<MudTd id="max-versions-val" DataLabel=@nameof(context.MaxVersion)>@context.MaxVersion</MudTd>
<MudTd id="can-alter-gnf-val" DataLabel=@nameof(context.CanAlterNightForwardingStatus)>@context.CanAlterNightForwardingStatus</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager HorizontalAlignment="HorizontalAlignment.Left" HidePagination="false" />
</PagerContent>
</MudTable>
Run Code Online (Sandbox Code Playgroud)
多谢。
尝试这个。overflow-wrap:break-word;max-width:200px;在你的行上。
max-width由于某种原因需要设置为 > 0 值,但您可以在样式中控制列的宽度ColGroup。
<RowTemplate>
<MudTd DataLabel="Nr">@context.Number</MudTd>
<MudTd DataLabel="Sign">@context.Sign</MudTd>
<MudTd DataLabel="Name" Style="overflow-wrap:break-word;max-width:10px;">@context.Name</MudTd>
<MudTd DataLabel="Position">@context.Position</MudTd>
<MudTd DataLabel="Molar mass" Style="text-align:right">@context.Molar</MudTd>
</RowTemplate>
Run Code Online (Sandbox Code Playgroud)