如何使用引导程序在一行中存在 3 个缩略图后创建新行

How to create new row after 3 thumbnails exist in one row with bootstrap

本文关键字:存在 略图 新行 创建 一行 引导程序 何使用      更新时间:2023-09-26

我想在每行放置 3 个缩略图,我使用的是"col-md-4"。但是,如果有 4+ 个缩略图,则会创建一个新行,并且 3 个缩略图将位于该新行中。我该怎么做?

 FB.api('/me/albums?fields=picture', 'get', {
   access_token: userToken
 }, function(response) {
   var data = response.data;
   for (var i = 0, l = response.data.length; i < l; i++) {
     var pictureUrl = data[i].picture.data.url;
     $("#albumPicturesModalBody").append("<div class='"col-md-4'"><a class='"thumbnail albumPicture'"><img src='"" + pictureUrl + "'" alt='"...'" class='"img-rounded'"></a></div>");
   }
 });
<div class="modal" id="albumPicturesModal" style="padding-top: 70px;" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">Select An Album</h4>
      </div>
      <div class="modal-body" style="max-height: 400px; min-height: 400px; overflow-y: scroll;">
        <div class="row" id="albumPicturesModalBody">
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

这是

对您的另一个问题的回答:"如何根据图像数量计算引导行数"

 function howManyRows(totalImages) {
        var count = Math.round(totalImages / 3);
        return count;
    }
    console.log(howManyRows(50)); // output: 17

您可以使用类似的东西来确定要在此处为您的其他函数请求创建多少行。