Results 1 to 3 of 3

Thread: cant get image to centre

  1. #1
    New Registered User homer93's Avatar
    Join Date
    Aug 2011
    Posts
    17

    Default 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

    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">&nbsp;</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">&nbsp;</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>'
    ;
            }

        }
    ?>
    [/FONT]
      Reply With Quote

  2. #2
    Trusted Guru Frinkky's Avatar
    Join Date
    Dec 2008
    Posts
    1,678
    Blog Entries
    1

    Default 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"
      Reply With Quote

  3. #3
    New Registered User homer93's Avatar
    Join Date
    Aug 2011
    Posts
    17

    Default 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
      Reply With Quote

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •