达到的内容如何在角度6中显示更多而显示更少 [英] How will achive content show more and show less in angular 6

查看:77
本文介绍了达到的内容如何在角度6中显示更多而显示更少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有6个内容分区.此外,我们在每个div处使用字符数限制. 我们使用了bootstrap 4 angular 6版本.

We have 6 content div. And also we using character limit each div. We used bootstrap 4 angular 6 version.

6 div打开或关闭某些div内容 如何达到这种情况.

6 div some toggle div content opened and some closed How to achive this case.

推荐答案

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

It's very easy to implement with some custom css. Give this a try:

模板:

<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;
}

组件:

show = false;

这是一个 示例StackBlitz 供您参考.

Here's a Sample StackBlitz for your ref.

这篇关于达到的内容如何在角度6中显示更多而显示更少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆