I generate a list of buttons dynamically. And the number of items is different between routes.
var app = angular.module("myApp", []);
app.controller("keysController", function keysController() {
var $ctrl = this;
$ctrl.keys = ["id", "destination", "body", "state", "createdDate", "processedDate"]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div ng-app="myApp" ng-controller="keysController">
<ul class="list-unstyled d-flex flex-wrap mb-0">
<li ng-repeat="key in $ctrl.keys">
<button type="button" ng-click="" class="btn mx-1">
{{key}}
</button>
</li>
</ul>
</div>
On Desktop, since there is enough space, all the items are on the same line. However, on small size screen, they are, at least, on two lines. In that case, they should take all the horizontal space.
Use this code, if you answer.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="list-unstyled d-flex flex-wrap mb-0">
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
id
</button>
</li>
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
destination
</button>
</li>
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
body
</button>
</li>
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
state
</button>
</li>
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
createdDate
</button>
</li>
<li>
<button type="button" ng-click="" class="btn btn-dark mx-1">
processedDate
</button>
</li>
</ul>
Update
It seems that I have not explained the issue clearly. So, I want to explain it further.
The ul
, li
, and button
should all be responsive. If the items are wrapped, it is fine. However, they should occupy all the space. For instance, if there is one item on a line, it should take all the line: its width should be equal to that of the line. If there are two, they should take the width of that line evenly.