我想自动调整引导列,我所说的“自动调整”是根据要显示的元素数量动态创建网格,我有以下 html:
<div class="vertical-center">
<div class="dashboard-options row panel">
<div class="panel-heading">
Menu
</div>
<div class="panel-body">
<!-- The followig <a> element is generated automatically using angular ng-repeat
This is an Angular Directive in fact, so that it's used in all the dashboards,
There are a lot of dashboards, and each has different amount of options,
This <a> element is setup to take 4 columns of the row, but sometimes there are
More than 3 <a> elements so a new row is generated, thats what i don't want -->
<a href="somewhere" class="col-md-4">
<div class="dashboard-option button-effect text-center">
<i class="fa fa-something"></i>
<p>Some Text</p>
</div>
</a>
</div>
</div>
</div>
我正在使用角度指令和 ng-repeat 来生成 html,这是指令:
<a href="somewhere" class="col-md-4">
<div class="dashboard-option button-effect text-center">
<i class="fa fa-something"></i>
<p>Some Text</p>
</div>
</a>
如您所见,它有一个col-md-4
类,这意味着只有 3 个元素可以排成一行,我想要的是,无论有多少元素(它们总是在 2 和 5 之间),这些元素都可以排成一行,无论它们是 2 还是 5,它们都应该放在一行中,如果它们是 4 个元素,那么<a>
类应该是col-md-3
,如果它们是 2 个元素,那么类<a>
应该是col-md-6
等等。
当我使用AngularJS时,有没有办法以角度方式做到这一点?我会在几个具有不同 Ctrl 的视图上使用它,所以如果可能的话,我会保持代码干燥。