html - CSS/Angular : Expanding a div

标签 html angular css typescript primeng

我的元素场景是:

当用户点击“Animals”图 block 时,它应该展开并替换其他图 block 。同样,点击“植物”图 block 时,它应该展开,其他图 block 应该重新排序。

===========第一个 View :============

enter image description here

===========第二个 View ============== enter image description here

第一页显示,平铺 View

第 2 页显示,单击磁贴时展开的 div。

请帮我实现这个。

我的代码如下。我能够显示隐藏展开的图 block ,但我无法隐藏用户单击并重新排序图 block 的图 block 。有什么提示可以实现这一目标吗?我不想展开和收缩动画。

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular 6';
  showDiv:boolean = false;
  showDetails():void{
    this.showDiv = !this.showDiv;
  }
}

<div *ngIf="showDiv" style="width:450px;height:150px;border:2px solid black">
  Expanded div
</div>
<br/>
<div (click)="showDetails()" style="width:100px;height:100px;border:2px solid black;clear:both;float:left">
  tile 1
</div>
<div style="width:100px;height:100px;border:2px solid black;float:left;margin-left:10px">
  tile 2
</div>
<div style="width:100px;height:100px;border:2px solid black;float:left;margin-left:10px">
  tile 3
</div>

最佳答案

我建议您为此使用 flexbox (css)。 单击这些图 block 只需更改 flexbox 属性。

关于html - CSS/Angular : Expanding a div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50167755/

相关文章:

javascript - 使用innerHTML 将文本放入文本框中

javascript - 根据日期重定向到不同的网页

angular - 打包后如何在 Electron 应用程序中获取开发工具? ( Electron 应用= angular2 + typescript )

javascript - 使用 javascript 更改 Bootstrap 3 导航栏的背景不透明度

javascript - 将一个网站上的输入文本框连接到另一个网站上的输入文本框?

angular - Ionic2/3 - 标题按钮图标的大小与自动后退按钮不同

angular - Firefox/Chrome 未在 2000 毫秒内被杀死,发送 SIGKILL

css - 如何在没有可见文本区域的情况下更改 Spotfire 中过滤器的 CSS?

html - 在屏幕尺寸上隐藏 div id

jquery - 使用 CSS 悬停时图像缩放