实现的内容如何在角度6中显示更多而显示更少

Amo*_*mol 1 bootstrap-4 angular angular6

我们有6个内容div。而且我们在每个div处使用字符限制。我们使用了bootstrap 4 angular 6版本。

6 div打开或关闭某些div切换内容 如何实现这种情况。

Sid*_*era 5

使用某些自定义CSS非常容易实现。试试看:

模板:

<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>
Run Code Online (Sandbox Code Playgroud)

CSS:

.container {
  font-size: 16px;
  line-height: 16px;
  height: 32px;
  overflow: hidden;
}

.show {
  overflow: visible;
  height: auto;
}
Run Code Online (Sandbox Code Playgroud)

零件:

show = false;
Run Code Online (Sandbox Code Playgroud)

这是供您参考的示例StackBlitz

  • @mhfour,我更新了我的示例StackBlitz以合并该行为。请看看。 (2认同)