我刚刚开始使用 masonry 插件,但我无法让它工作。下面是问题的图片。
如您所见,这不是预期的效果。以下是我正在使用的代码:
内容
<div class="container" id="reviews">
<div class="row">
<div class="comment-block">
<div class="new-comment"></div>
<?php
while($row = mysqli_fetch_array($result)) {
$data = mysqli_fetch_array(mysqli_query($con, "SELECT first_name, last_name FROM transactions WHERE order_id = '{$row['order_id']}'"));
$name = $data['first_name']. ' '. mb_substr($data['last_name'], 0, 1);
if($row['rating'] == 5) $star = '<span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span>';
if($row['rating'] == 4) $star = '<span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span>';
if($row['rating'] == 3) $star = '<span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span>';
if($row['rating'] == 2) $star = '<span class="glyphicon glyphicon-star review_star"></span><span class="glyphicon glyphicon-star review_star"></span>';
if($row['rating'] == 1) $star = '<span class="glyphicon glyphicon-star review_star"></span>';
?>
<div class="col-md-4">
<div id="box_review">
<h3><?php echo $star; ?></h3>
<h5 class="thin"><?php echo $row['date'] ?></h5>
<blockquote>
<p><?php echo $row['comment'] ?></p>
<footer><?php echo $name ?></footer>
</blockquote>
</div>
</div>
<?php } ?>
</div><!-- ./ comments block -->
</div><!-- ./ row -->
</div><!-- ./ container -->
石工
$(document).ready(function() {
$('#reviews').masonry({
columnWidth: 400,
itemSelector: '#box_review'
}).imagesLoaded(function() {
$('#reviews').masonry('reload');
});
});
请你能帮我解决我做错了什么吗?我也将 Bootstrap 用于网格系统,顺便说一下,我不确定这是否可能是问题所在。谢谢。