我從我的數據庫拉我的圖像,並嘗試將它們排序列出,而不是上下。有誰知道如何做到這一點?砌體CSS訂單
我的CSS:
#myContent {
-moz-column-count: 3;
-moz-column-gap: 0px;
-webkit-column-count: 3;
-webkit-column-gap: 0px;
column-count: 3;
column-gap: 0px;
width: 900px;
}
#myContent img{
display: inline-block;
margin-bottom: 0px;
width: 90%;
}
我HTML和PHP
<ul id="myContent">
<div id="postedComments">
<?php
$result = mysql_query("SELECT * FROM stories ORDER BY pid ASC limit 0 , 5");
while($data = mysql_fetch_array($result)) {
$pid = $data['pid'];
$photo_url = $data['photo_url'];
echo "<div class='postedComment' id=\"$pid \">
<img src='$photo_url'>
<p>pid: $pid</p>
<hr />
</div>" ;
}
?>
</div>
</ul>
很多代碼已被棄用/不推薦使用'center'和'br'。嘗試剝離所有東西,只是「浮動:左邊」圖像。這將使他們都對齊,當他們不適合,去下一行 – Andy
好吧,剛剛更新我的PHP到mysql_fetch_array,剝離了CSS並添加了浮動:左;但結果是沒有對準下一行 – Hector
他們不會一致,除非你用磚石(jQuery插件),或添加容器 – Andy