Nous avons 6 div de contenu. Et nous utilisons également des caractères pour limiter chaque div. Nous avons utilisé bootstrap 4 angular 6).
6 div certains bascule le contenu div ouvert et certains fermé Comment atteindre ce cas.
Il est très facile à implémenter avec des CSS personnalisés. Essayez ceci:
Modèle:
<div class="container" [class.show]="show">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<button (click)="show = !show">{{ show ? 'Show less': 'Show More' }}</button>
CSS:
.container {
font-size: 16px;
line-height: 16px;
height: 32px;
overflow: hidden;
}
.show {
overflow: visible;
height: auto;
}
Composant:
show = false;
Voici un Sample StackBlitz pour votre référence.
Vous pouvez utiliser <ng-container>
qui ne crée pas de noeuds html supplémentaires
<div class="container" [class.show]="show">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur a felis odio. Nam et feugiat purus.
Nunc non ex mi. Phasellus at arcu id tortor gravida pellentesque.
<ng-container *ngIf="showMore1">
Duis enim justo, placerat non dui non, placerat semper est.
Ut pulvinar aliquet lectus vulputate rutrum.
Maecenas suscipit, sapien ut fermentum hendrerit,
nibh augue scelerisque felis, in fermentum elit augue sed odio.
...
</ng-container>
</div>
<button (click)="showMore1= !showMore1">show {{showMore1 ?'less':'more' }}</button>