使用 Bootstrap 和 AngularJS,有没有办法为每组ng-repeat
元素水平地添加一个新行?
我一直在ng-class
努力实现这一点Fiddle,但问题是我无法在初始行 div 中获得浮动左 div ...... ?
这是我的代码(上面小提琴链接中的实时示例):
<body ng-app="myApp">
<div ng-controller="MyCtrl">
<div ng-repeat="num in numbers"
ng-class="{'row': ($index)%2==0, 'col-md-6': ($index)%2!=0}">
<div ng-class="{'col-md-6': ($index)%2==0}">
{{num}}
</div>
</div>
</div>
</body>
var myApp = angular.module('myApp', [])
.controller('MyCtrl', function ($scope) {
$scope.numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
});
.row {
clear: both;
width: 100%;
border: 1px solid red;
}
.col-md-6 {
width: 50%;
float: left;
border: 1px solid blue;
}