【问题标题】:angularjs html tag's styleangularjs html标签的样式
【发布时间】:2017-06-23 17:46:37
【问题描述】:

我有一些 html

<div ng-style="multiStyle(row)" ng-repeat="row in search_result | filter:cacheTemplate track by $index">

事先我不知道这个 div 的高度。它可能是 60 像素或 80 像素,具体取决于屏幕。是否可以将此 div 的 mutliStyle(row, height) 高度作为参数发送到函数中?或者将这个 div 发送到这个函数中,以便在我的函数中得到这个高度?

【问题讨论】:

  • 如果您使用的是引导程序,您可以使用响应式实用程序getbootstrap.com/css/#responsive-utilities,它根据屏幕大小应用 css。你想达到什么目的?
  • @MattjeS 我不使用 bootsrtap。我需要在我的函数中获取这个 div 的高度,以便用新值重新分配高度。
  • 设置新高度的逻辑是什么?你可以在函数中使用javascript获取高度,如果行有一个id,比如索引,将它传递给函数,multiStyle(row, $index)

标签: javascript css angularjs


【解决方案1】:

你为什么不使用 css ?
你可以简单地写一个这样的媒体查询

@media screen and (max-height: 500px) {
   ...
}

这里描述了另一种解决方案: How to access to the current element with ng-style

【讨论】:

  • 我已经在用这个了。因为@media,我遇到了这个问题。
  • 您是否尝试实现指令来获取元素?
猜你喜欢
  • 1970-01-01
  • 2012-12-20
  • 1970-01-01
  • 1970-01-01
  • 2015-08-24
  • 1970-01-01
  • 1970-01-01
  • 2012-09-23
  • 2012-08-31
相关资源
最近更新 更多