Jump to content

Recommended Posts

.centered {

top: 50%;

left: 50%;

width: 80px;

height: 130px;

background-image: url(images/stand.gif);

background-repeat: no-repeat;

}

.cent {

margin-left: auto;

margin-right: auto;

}

<table align="center" >
  <tr>

    <?php
$Recordset1_endRow = 0;
$Recordset1_columns = 10; // number of columns
$Recordset1_hloopRow1 = 0; // first row flag
do {
    if($Recordset1_endRow == 0  && $Recordset1_hloopRow1++ != 0) echo "<tr>";
   ?>
    <td align="center"><div class="centered"><div><img src="images/flag/<?php echo $row_Recordset1['country']; ?>.gif"></div><?php echo $row_Recordset1['username']; ?><div class="cent"><img src="images/floga.gif" /></div></div></td>
    <?php  $Recordset1_endRow++;
if($Recordset1_endRow >= $Recordset1_columns) {
  ?>
  </tr>
  <?php
$Recordset1_endRow = 0;
  }
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
if($Recordset1_endRow != 0) {
while ($Recordset1_endRow < $Recordset1_columns) {
    echo("<td> </td>");
    $Recordset1_endRow++;
}
echo("</tr>");
}?>
</table>

 

how to .cent  align to center?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/231281-how-to-div-in-div-centerent/
Share on other sites

could you instead of posting your php (which is a serverside script) post the outputed html. or maybe link to online content so we can inspect it.

Btw, why on earth are you placing div's in a table. and why are you using tables for this?

 

-edit: btw to center a div (or any block element, you first need to give it a width other than 100% (which is the default value)

 

<style>
.centered {
top: 50%;
left: 50%;
width: 80px;
height: 130px;
background-image: url(images/stand.gif);
background-repeat: no-repeat;
}





.cent {
margin-left: auto;
margin-right: auto;
}







  </style>

<table align="center" >
  <tr>

    <td align="center"><div class="centered"><div></div><div class="cent"></div></div></td>


  </tr>
</table>

how to the second div aligh center? i whant add one image in div center

 

did you read the link it added?

 

anyway i gave the things some color and indentation: easier to see what you do:

not sure if this is what you want, but the cryptic: how to div in div... doesn't make it any clearer

<style type="text/css">
.centered {
top: 50%;
left: 50%;
width: 80px;
height: 130px;
background-image: url(images/stand.gif);
background-repeat: no-repeat;
        border:1px solid red;
}
.cent{
margin-left: auto;
margin-right: auto;
        min-height: 10px;
        width:20px;
        background:#000;
}
</style>

<table align="center" >
  <tr>
    <td align="center">
        <div class="centered">
            <div></div>
            <div class="cent"></div>
        </div>
    </td>
  </tr>
</table>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.