gpt4 book ai didi

php - 砌体 CSS 命令

转载 作者:行者123 更新时间:2023-11-28 13:32:19 25 4
gpt4 key购买 nike

我正在从我的数据库中拉出我的图像,并尝试将它们排序到横向列表而不是上下列表。有谁知道如何实现这一点?

Screenshot of Current Output

我的 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>

最佳答案

在您希望位于一行中的图像上使用“float:left”。确保在所有图像之后使用类似这样的东西,这样图像之后的 HTML 才会起作用:

.clear{
clear:both;
height:1px;
margin-bottom:-1px;
}

<div>
//Your pictures
</div>
<div class="clear"></div>

关于php - 砌体 CSS 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13419946/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com