简体   繁体   English

如何使div成为另一个

[英]How to make to div comes the one under the other

Hello i'm creating a pagination script , i already done everything and now i'm trying to make the index page , it will contain the data retrieved from the database and i wanted to be represented on the form of 2 divs the first for the thumbnail and the other will contain the title under the thumbnail. 您好,我正在创建一个分页脚本,我已经做完了所有事情,现在我正在尝试制作索引页,它将包含从数据库中检索到的数据,我想以2 divs的形式表示缩略图,另一个将在缩略图下方包含标题。 So here is my code : here is the looping it's ok for it i just want you to see the html code inside. 所以这是我的代码:这是循环,没关系,我只希望您看到其中的html代码。

$brk_cnt = 0;

while($row = mysqli_fetch_array($results))
{
 echo ' <td>
        <div class="datamore">'.$row['thumbnail'].'</div><div class="data1r1">$row['title']</div>
        </td>';

 //break or print <tr> condition
 if(++$brk_cnt % 4 == 0)
 {
    echo '</tr><tr>';
 }
}


echo '</table>';

and the css : 和CSS:

.data1r1 {
width:198px;
height:235px;
background-color:#4D72B7;
border-radius:5px;
/* border shits */
border:1px;
border-color:black;
border-style:solid;
border-radius:5px;
clear:both;

}
.datamore {
width:198px;
height:150px;
background-color:#C7441A;
position:absolute;
border-radius:5px;
clear:both;
}
#table {
    margin-left:250px;
    margin-top:20px;
    position:absolute;
}

I though i'm using the proper css at first but when printing data it's not a good result here is how the divs looks like : 我虽然一开始使用的是正确的CSS,但是在打印数据时,这里的div效果不是很好:

股利
(source: hostingpics.net ) (来源: hostingpics.net

the 2 divs are supperposed the one on the other .. i want to get the blue one under the orange one. 2个div重叠在另一个div上..我想将蓝色的div放在橙色的div之下。 Thanks sorry for this long description but i wanted to make things clear. 谢谢您对这个冗长的描述,但我想说清楚。

remove the position:absolute 删除位置:绝对

.datamore {
 width:198px;
 height:150px;
 background-color:#C7441A;

 border-radius:5px;
 clear:both;
}

Example

replace the position:absolute to position:relative 替换位置:绝对位置:相对

.datamore {
width:198px;
height:150px;
background-color:#C7441A;
position:relative;
border-radius:5px;
clear:both;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM