JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container" ng-controller="GroupController">
<div class="row" ng-repeat="group in groups">
<div class="col-xs-6 col-sm-4 col-md-3 card" ng-repeat-start="item in group">
<div class="inner">Item {{ item }}</div>
</div>
<div class="divider" ng-repeat-end ng-click="create_group($parent.$index, $index)">
Click here to add a section
</div>
</div>
</div>
SCSS
.row {
margin-top: 15px;
margin-bottom: 15px;
background: #f9f9f9;
}
.card {
margin-top: 15px;
margin-bottom: 15px;
.inner {
height: 150px;
line-height: 150px;
background: #eee;
text-align: center;
}
}
// Hidden divider
.divider {
display: none;
float: left;
width: 100%;
height: 30px;
cursor: pointer;
line-height: 30px;
text-align: center;
opacity: 0;
transition: opacity 0.4s ease;
&:hover {
opacity: 1;
}
// Show divider after every two items
&:nth-child(4n) {
display: block;
}
// Hide last divider in group
&:last-child {
display: none !important;
}
}
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
.divider:nth-child(4n) {
display: none;
}
.divider:nth-child(6n) {
display: block;
}
}
/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) {
.divider:nth-child(4n) {
display: none;
}
.divider:nth-child(6n) {
display: none;
}
.divider:nth-child(8n) {
display: block;
}
}
JavaScript
var app = angular.module('itemsApp', []);
app.controller('GroupController', ['$scope', function($scope) {
$scope.groups = [
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
];
$scope.create_group = function(group, index) {
index = index + 1;
var get_group = $scope.groups[ group ];
$scope.groups[ group ] = get_group.slice(0, index);
$scope.groups.splice( group + 1, 0, get_group.slice(index) );
};
}]);