作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有 6 个内容分区。我们还使用字符限制每个 div。我们使用 Bootstrap 4 Angular 6 版本。
6 div some toggle div content opened and some closed如何实现这个案例。
最佳答案
使用一些自定义 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>
CSS:
.container {
font-size: 16px;
line-height: 16px;
height: 32px;
overflow: hidden;
}
.show {
overflow: visible;
height: auto;
}
组件:
show = false;
这是一个Sample StackBlitz供您引用。
关于angular - 如何在 Angular 6中实现内容显示更多和显示更少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53372022/
我是一名优秀的程序员,十分优秀!