Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 更改deckgrid中最后一张卡的宽度_Angularjs_Css_Angularjs Ng Repeat - Fatal编程技术网

Angularjs 更改deckgrid中最后一张卡的宽度

Angularjs 更改deckgrid中最后一张卡的宽度,angularjs,css,angularjs-ng-repeat,Angularjs,Css,Angularjs Ng Repeat,所以我使用角网格来显示图像。我有两列用于显示带有column-1-2类的图像,如容器中的文档所述。现在,在某些情况下,它们的最后一行只有一个图像,在这种情况下,我想让图像占据整个宽度,而不是50%的空间 现在这是两列的渲染方式: <div deckgrid="" class="deckgrid ng-isolate-scope" source="loves"> <div data-ng-repeat="column in columns" class="column co

所以我使用角网格来显示图像。我有两列用于显示带有column-1-2类的图像,如容器中的文档所述。现在,在某些情况下,它们的最后一行只有一个图像,在这种情况下,我想让图像占据整个宽度,而不是50%的空间

现在这是两列的渲染方式:

<div deckgrid="" class="deckgrid ng-isolate-scope" source="loves">
   <div data-ng-repeat="column in columns" class="column column-1-2">
      <div data-ng-repeat="card in column" data-ng-include="cardTemplate" class="ng-scope"> "my card layout here" </div>
      <div data-ng-repeat="card in column" data-ng-include="cardTemplate" class="ng-scope"> "my card layout here" </div>
      <div data-ng-repeat="card in column" data-ng-include="cardTemplate" class="ng-scope"> "my card layout here" </div>
   </div>
   <div data-ng-repeat="column in columns" class="column column-1-2">
      <div data-ng-repeat="card in column" data-ng-include="cardTemplate" class="ng-scope"> "my card layout here" </div>
      <div data-ng-repeat="card in column" data-ng-include="cardTemplate" class="ng-scope"> "my card layout here" </div>
   </div>
</div>
但是如何检查第一列和第二列在css中是否有不相等的子级呢


谢谢

也许我弄错了,但是您可以将ng repeat的$last属性组合到ng类中。它将把类
mylast child
添加到ng repeat的最后一个div中

 <div data-ng-repeat="card in column" 
      data-ng-include="cardTemplate" class="ng-scope"
      ng-class="{'mylast-child': $last}" > 
             "my card layout here"
 </div>


 .mylast-child {
     width:200%!important;
 }

您可能希望使用内置的角度函数

var firstChildCount =  angular.element(angular.element(".column")[0]).find('div').length;
var secondChildCount =  angular.element(angular.element(".column")[1]).find('div').length;

if(firstChildCount  !== secondChildCount ){
     //Apply CSS
}

实际上,这些ng重复是从那个插件动态添加的,它不在我的模板中编辑哪个插件?您不能更改html?网格,我只需要包括以下内容:-“我的卡片内容在这里”上面的html是由pluginok生成的。对不起,这件事我帮不了你。我不太了解css,但它应该是获取节点最后一项的一种方法
Variable |  Type     |  Details
--------------------------------
$index   |   number |    iterator offset of the repeated element (0..length-1)
$first   |   boolean |  true if the repeated element is first in the iterator.
$middle  |  boolean | true if the repeated element is between the first and last in the iterator.
$last    |   boolean |  true if the repeated element is last in the iterator.
$even    |   boolean |  true if the iterator position $index is even (otherwise false).
$odd     |   boolean |  true if the iterator position $index is odd (otherwise false).
var firstChildCount =  angular.element(angular.element(".column")[0]).find('div').length;
var secondChildCount =  angular.element(angular.element(".column")[1]).find('div').length;

if(firstChildCount  !== secondChildCount ){
     //Apply CSS
}