Results 1 to 3 of 3
Thread: cant get image to centre
-
cant get image to centre
8 Aug 2011 @ 12.30 [FONT=Verdana]hi everyone
ive got some php script which generates a div array, which i then echo onto the body of the page.
in part of the div i have a photo which spans the width of the div, 100px i think. i cant get the photo to vertically align in this div. ive tried adding an id and a class but neither seems to centre in, any ideas? thanks
[/FONT]PHP Code:<?php
phpif (isset($_GET['bid'])) {
$DPView = "";
$detailPhotoView = "";
$targetID = $_GET['bid'];
$Bsql = mysql_query("SELECT * FROM builds WHERE id = $targetID");
while ($row = mysql_fetch_array($Bsql)){
$DP = $row["photo"];
$DetailPs = $row["detail_photos"];
$DetailPA = explode(',',$DetailPs);
$DPsql = mysql_query("SELECT * FROM photos WHERE id = $DP");
$DPD = mysql_result($DPsql,0,'details');
foreach ($DetailPA as $DetailP){
$DetailP = $DetailP;
$DetPsql = mysql_query("SELECT * FROM photos WHERE id = $DetailP");
while ($row = mysql_fetch_array($DetPsql)){
$DetailPD = $row["details"];
$detailPhotoView .='
<div id="listItem">
<div style="float:left; width:210px; height:179px" class="left">
<div style="height:160px"><img src="../db_images/'.$DetailP.'.jpg" width="200" /></div>
<div height:19px align="right">Delete | Submit</div>
</div>
<div style="float:left; width:10px"> </div>
<div style="float:left; width:695px; height:179px" id="detail">Details:<br />
<textarea name="details" id="details" cols="70" rows="8">'.$DetailPD.'</textarea>
</div>
</div>';
}
}
$DPView .= '
<div id="listItem">
<div style="float:left; width:210px; height:179px" class="left">
<div style="height:160px">
<img src="../db_images/'.$DP.'.jpg" width="200" style="align="center; vertical-align:middle" />
</div>
<div height:19px align="right">Delete | Submit</div>
</div>
<div style="float:left; width:10px"> </div>
<div style="float:left; width:695px; height:179px" id="detail">Details:<br />
<textarea name="details" id="details" cols="70" rows="8">'.$DPD.'</textarea>
</div>
</div>';
}
}
?>
-
8 Aug 2011 @ 12.33 Try adding the vertical-align:middle to the containing div instead of the img itself. If that fails, there's quite a breakdown of how/when to use vertical-align here: Understanding vertical-align, or "How (Not) To Vertically Center Content"
-
8 Aug 2011 @ 14.10 ahh got it, i put it into the div as you said.but i had to put
display:table-cell
verticle-align:middle
thanks



LinkBack URL
About LinkBacks












Help needed please
Can you link to a web page showing the problem? That makes it much...