Need solution

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
could any body can help me in HTML/CSS

i have one div and its width and height is 200px; and one child div its
height and width is 50px;
now i want that child div in center of the parent div. child div could
be more than one may be 5. all should be center aligned and inlined.
can any body help me pls :)

Re: Need solution

Sunil wrote:
Quoted text here. Click to load it

Do you mean up to (5) 50px squares stacked vertically within (1) 200px
square? If so, math will be your enemy, 50x5=250, what are you going to
do with the overflow? Also, with compliant browsers if you specify
border, padding, and margin for the child DIVs, that will also be added
to the total!

Take care,

Re: Need solution

Thanks Jonathan

actually the parent Div's width is 800px; and child div's width is
50px; and it can't be more than 5. and i want all 5 child divs in
center of the parent div.

1. child div could 1 or 2 or 3 or 4 or 5.
2. the all child divs should be inline.

waiting for you reply.

thanks in advance.

Jonathan N. Little wrote:
Quoted text here. Click to load it

Re: Need solution

Sunil wrote:
Quoted text here. Click to load it

Just fill in the input and look at the source.

If you want the algorithm, here is the php function.
$cells is an array of the content.

$cellpadding=1, $cellmargin=1,$cellborder=1){

    foreach($cells as $cell)
       $r.="<div style=\""."width:$cellwidth"."px;
height:$cellheight"."px; margin:$cellmargin"."px;border:solid

    if($maxcols > $numcells)$cols=$numcells;else $cols=$maxcols;
    $width+=1;// neccesary for internet explorer
    $r="<div style=\""."width:$width;margin:$topmargin"."px
    return $r;

Site Timeline