【问题标题】:I want to dynamically change the parent and child div's height based on the window resize using angular我想根据窗口调整大小使用角度动态更改父子div的高度
【发布时间】:2019-09-25 09:53:23
【问题描述】:

有两个 div col-6,在每个 div 中,我有多个 div。

如果我使用滚动调整窗口大小,每个 div 下方都会出现空白。

我需要根据窗口大小增加 div 的高度,还需要在我的.ts 文件角度中更改内部 div 的高度。

我尝试使用@Hostistner,但只有外部 div 高度发生变化

【问题讨论】:

  • 使用 css 网格在每个 col-6 内布局 div。如果您发布您想要的布局并将css 标签添加到问题中,您将获得一些基于css 的建议。或者使用@ViewChild@ViewChildren 抓住孩子,并随着父母身高的变化而改变他们的身高。
  • 你能告诉我如何使用@ViewChild 改变高度
  • 也许你可以使用 css vh (view-height) 单位。看:w3schools.com/cssref/css_units.asp 将父 div 设置为 100vh,因此无论窗口大小,它们始终处于全高状态。

标签: javascript angular


【解决方案1】:

您需要使用 css 将所有孩子的身高设为 100%。或者试试 Gridster 组件,它会让这些布局变得容易 https://tiberiuzuld.github.io/angular-gridster2/

【讨论】:

    猜你喜欢
    • 2013-06-06
    • 1970-01-01
    • 2013-09-11
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 2012-09-06
    • 2011-02-15
    • 1970-01-01
    相关资源
    最近更新 更多