php - Divs are overlapping on accident -
php - Divs are overlapping on accident -
i have posts echoed out of mysql database. if there more one, echoed in separate divs in order of decreasing rank number (taken db). however, when divs echoed, overlap on top. believe css problem. thing each div has several sub divs. think "position" attribute might have contributed this. each div echoed out 100px between each one. thanks.
code:
$post = array(); $f=0; while ($row=mysql_fetch_assoc($g)){ $post[]=$row['post']; echo "<div id='area'>"; echo "<div id='badge'><span style='color: gray;'>answered by:</span>"; include 'badge.php'; echo "</div>"; echo "<div id='areapost'><pre>$post[$f]</pre></div>"; $f++; } echo "</div>"; /*end area*/
css code:
#area { background-color: #fff; border: 1px solid red; width:500px; height: 300px; } #badge{ position: absolute; top: 0px; left: 0px; } #areapost{ position: absolute; top: 0px; right: 0px; height: 300px; width: 380px; background-color: #e0e0e0; overflow: -moz-scrollbars-vertical; overflow-x: hidden; overflow-y: scroll; }
the "area" entire post container. areapost , badge elements within "area"
you need open , close divs @ same level of looping. here opening <div id='area'>
within while loop , closing outside while loop. need either both in, or both out. also, id's ought unique, on whole page, else should using classes on divs.
you need not position these areas absolutely. i've added content div
around everything. position absolutely, , area class relatively. don't need styling on #area
, alter .area
.
$f=0; echo "<div id='content'>" while ($row=mysql_fetch_assoc($g)){ $post[]=$row['post']; echo "<div id='area-'" + $f + " class='area'>"; echo "<div class='badge'><span style='color: gray;'>answered by:</span>"; include 'badge.php'; echo "</div>"; echo "<div class='areapost'><pre>$post[$f]</pre></div>"; echo "</div>"; /*end area*/ $f++; } echo "</div>"
php html spacing
Comments
Post a Comment