0
我試圖動態地在div
內附加卡片。JQuery追加跳過空格後的內容
我的代碼做如下:
$.getJSON(url, function(jsonresult2) {
for (var i = 0; i < 30; i++) {
phototemp = link_to_photo;
itemname = link_to_item_name;
itemcategory = link_to_item_category;
$("#populateexplore")
.append('
<div class="col-lg-3 col-md-4 col-sm-6" style="float:left">
<div class="card"><img src="'
+ phototemp
+ '" style="width:100%;height:200px;"><div class="container"> <h4> <b> '
+ itemname
+ '</b></h4><hr><p>Category:'
+ itemcategory
+ '</p></div></div></div>');
}
}).error(function() { sweetAlert("Cannot find the place"); });
卡div
的CSS是
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
border-radius: 5px; /* 5px rounded corners */
background-color: #CCC;
margin-bottom: 10px;
}
的問題是,輸出CADS不浮在左側而是給左邊的空白空間
https://i.imgur.com/ols6AVx.jpg
有沒有什麼辦法可以填補左側的空白空間?
如果你正在使用引導網格系統,那麼爲什麼你添加(浮動:左)網格系統已經擁有它。 –
@yahya 刪除它不會影響輸出。它仍然向右。 我只是給它一個試試:) – Pujan
我不能確定,因爲我沒有完整的代碼,或者如果你可以給網站鏈接,可能有所幫助.. –