很长一段时间以来,我一直在寻找解决方案。如何将 div 垂直推到一起(见附图)。
有人建议使用特定的 CSS 编码,但在这种情况下这并不好,因为没有设置 div 高度 - 它会根据加载的内容而变化。
------------------添加信息------------------
根据要求,这是使用数据库中的内容填充 div 的代码。只需将 div 向上推,如附图所示。
<?php
require_once('../scripts/include.php');
$who = 65; //temp value to be deleted
$result = mysql_query(
"SELECT
tbl_status.id as statID,
tbl_status.from_user as statFROM,
tbl_status.status as statSTATUS,
tbl_status.deleted as statDEL,
tbl_status.date as statDATE,
tbl_users.id as usrID,
tbl_users.name as usrNAME,
tbl_users.location as usrLOCATION,
tbl_photos.profile as photosPROFILE,
tbl_photos.photo_link as photoLINK,
tbl_photos.default_photo as photoDEFAULT
FROM tbl_status
LEFT JOIN tbl_users ON tbl_status.from_user = tbl_users.id
LEFT JOIN tbl_photos ON tbl_photos.profile = tbl_users.id
WHERE tbl_status.deleted = '0' AND tbl_photos.default_photo IS NULL OR tbl_photos.default_photo = '1'
ORDER BY tbl_status.date desc
LIMIT 24
");
while($row = mysql_fetch_array($result))
{
$sampleText = $row['statSTATUS'];
$pattern = '/#[a-zA-Z0-9]*/';
$replacement = '<a href="../search/term.php?$0" class="hashSearch">$0</a>';
$updatedText = preg_replace($pattern, $replacement ,$sampleText);
echo'
<div class="statusCont" style="width:150px;">
<div class="statusUsr">' . $row['usrLOCATION'] . '</div>
<div class="statusTxt"><p>' . $updatedText . '</p></div>
<div class="statBackground" style="background-image:url(../assets/uploads/resized_' . $row['photoLINK'] .');
background-repeat:no-repeat; background-size:100%;width:150px; height:50px; opacity:1;"></div>
</div><!-- ends .statusCont -->
';}
?>