我在每个项目之间设置了 5px 的填充,但是 5px + 5px 在兄弟项目之间变为 10px(水平,垂直也有 10px)
http://plnkr.co/edit/7FKBiTocHrTuwnpEqQsu?p=preview
// Code goes here
angular.module('app', [])
.controller('MainCtrl', function($scope){
$scope.items = Array(10);
})
/* Styles go here */
*, :after, :before {
box-sizing: border-box;
}
.one.fifth {
width: 20%;
}
.one.whole{
width: 100%;
}
.pad {
padding: 5px;
}
.red {
color: red;
}
.box {
float: left;
position: relative;
}
.red.box {
background-color: red;
}
.white.box {
background-color: white;
}
.black.border {
border: 1px solid #000;
}
.center {
text-align: center;
}
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
</head>
<body class="one whole">
<div ng-controller="MainCtrl">
<div class="red box pad center">
<div class="white box">
<div class="one fifth box pad" ng-repeat="item in items track by $index">
<div class="one whole black border box">TEST {{$index}}</div>
</div>
</div>
</div>
</div>
</body>
</html>
有什么方法可以在所有内容之间获得 5px 精确的填充或间距?
注意:我尝试过 + 运算符,但是对第六项有副作用,因为这 10 项是同级的