Utilizing AngularJS ng-repeat for displaying a list of products and incorporating bootstrap col-md-2 to showcase 6 products in each row, I have included a condensed version of my code below:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of Bootstrap 3 Grid System</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap- theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>
<style type="text/css">
p{
padding: 50px;
font-size: 32px;
font-weight: bold;
text-align: center;
background: #f2f2f2;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-2" ng-repeat="item in items">
<img src="{{itme.imgURL}}" />
<p>{{item.title}}</p>
<div>
<a href="{{item.productURL}}" />
</div>
</div>
</div>
</div>
</body>
Some product titles are lengthy, causing them to span multiple lines and disrupt the alignment of elements. To observe this misalignment, please test the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of Bootstrap 3 Grid System</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap- theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>
<style type="text/css>
p{
padding: 50px;
font-size: 32px;
font-weight: bold;
text-align: center;
background: #f2f2f2;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-2"><p>Box 1 test</p></div>
<div class="col-md-2"><p>Box 2</p></div>
<div class="col-md-2"><p>Box 3</p></div>
<div class="col-md-2"><p>Box 4</p></div>
<div class="col-md-2"><p>Box 5</p></div>
<div class="col-md-2"><p>Box 6</p></div>
<div class="col-md-2"><p>Box 7</p></div>
<div class="col-md-2"><p>Box 8</p></div>
<div class="col-md-2"><p>Box 9</p></div>
<div class="col-md-2"><p>Box 10</p></div>
<div class="col-md-2"><p>Box 11</p></div>
<div class="col-md-2"><p>Box 12</p></div>
</div>
</div>
</body>
</html>
In this scenario, Box 7 appears below Box 2 instead of being aligned under Box 1.
Although adding a clearfix div before Box 7 or placing elements 7-12 in a new bootstrap row can resolve the issue, due to using ng-repeat, individual control over each element is limited.
If anyone has suggestions on achieving proper alignment of all elements, it would be greatly appreciated!