使用角度/ 4材料,如何使用每行芯片旁边的文本垫片?

问题描述 投票:0回答:1

使用angular2 / 4,我想在单个芯片旁边使用mat-chip(https://material.angular.io/components/chips/overview)文本,并为每个“条目”占用整个宽度(div中的单行)。其他条目应该像正在运行的聊天一样显示在彼此之下。现在我有:

我目前的代码如下,但它看起来并没有达到预期的效果......

<div class="rectanglebox" style="width:300px;height:500px;">
<div style="float:left">
<mat-chip-list>
  <mat-chip>A</mat-chip>
</mat-chip-list>
</div>
<div style="float:left">Text for A that is really long and may overflow. If it does, the chip should remain to the left side and not move all the text to a new dedicated line.</div>
</div>
</div>
<div style="float:left">
<mat-chip-list>
  <mat-chip>B</mat-chip>
</mat-chip-list>
</div>
<div style="float:left">Text for B</div>
</div>
<div style="float:left">
<mat-chip-list>
  <mat-chip>C</mat-chip>
</mat-chip-list>
</div>
<div style="float:left">Text for C</div>
</div>

更新了样本,显示所有文本如何在芯片下方“如果它太长而不是缠绕它”:qazxsw poi

html css angular
1个回答
1
投票

你可以使用https://stackblitz.com/edit/angular-ijhhz3-fn56yj?file=app/chips-overview-example.html作为你要显示的div,我已经修改了你可以在这里查看的HTML,修复div你需要使用css的postion属性。我用style="display: inline-block"了解更多你可以检查position: absolute

here

看看 <div class="rectanglebox" style="width:300px;height:500px;"> <div style="display: inline-block;position: absolute;"> <mat-chip-list> <mat-chip>A</mat-chip> </mat-chip-list> </div> <div style="display: inline-block;margin-left: 45px;">Text for A where something is super long that ehrere sids sdis fdf ds f sdf sd fs d fs fsd f s fsd f sf df s fs fd Text for A where something is super long that ehrere sids sdis fdf ds f sdf sd fs d fs fsd f s fsd f sf df s fs fd Text for C long that ehrere sids sdis fdf ds f sdf sd fs d fs fsd f s fsd f sf df s fs fd margin-left: 45px;</div> <div> <div style="display: inline-block;position: absolute;"> <mat-chip-list aria-orientation="vertical"> <mat-chip>B</mat-chip> </mat-chip-list> </div> <div style="display: inline-block;margin-left: 45px;">Text for B Text for A where something is super long that ehrere sids sdis fdf ds f sdf sd fs d fs fsd f s fsd f sf df s fs fd margin-left: 45px;</div> </div> <div style="display: inline-block;position: absolute;"> <mat-chip-list> <mat-chip>C</mat-chip> </mat-chip-list> </div> <div style="display: inline-block;margin-left: 45px;" >Text for C long that ehrere sids sdis fdf ds f sdf sd fs d fs fsd f s fsd f sf df s fs fd margin-left: 45px;</div> </div>

© www.soinside.com 2019 - 2024. All rights reserved.