Click to See Complete Forum and Search --> : aligniing divs - the sequel


cssrules
02-02-2003, 09:05 PM
hi!

i am aware that there is another thread that has to do with aligning a div.....yet i could find an answer to the specific problem...so i am asking again...


i have a parent div (pageBody) and in it another div and some text...

div#pageBody {
width: 620px;

}

what i need to do is align the parent div horizontally in the middle....well adding text-align: center appears to do the job on IE but due to a bug...:mad:

on Mozilla the parent div stays always on the left...


how can it be done...

Thanl u in advance....

Stefan
02-03-2003, 01:45 AM
Originally posted by cssrules
[B]hi!
what i need to do is align the parent div horizontally in the middle....well adding text-align: center appears to do the job on IE but due to a bug...:mad:

on Mozilla the parent div stays always on the left...

how can it be done...


The correct way to center a div with CSS is

div#pageBody {width: 620px; margin:0 auto;}

cssrules
02-03-2003, 06:52 AM
thank you for your answer...

i have used this code

div#parentDiv {
width: 620px;
text-align:center;
margin: auto;
}

and it works under IE and Mozilla...I have also changed the text-align (due to inherit) to divs-content of the page....

i know though that by removing the text-align attribute IE will fail to horizontally center the div's content, whereas Mozilla has no such problem..

how can it be done without the text-align? i have read it is due to a bug that actually causes the content of the page to be centered....

Anyway, if there is no answer, i'll probably stick to the above code...If something ain't broken, why fix it?:D

Thank u in advance.... :cool:

Stefan
02-03-2003, 08:33 AM
Originally posted by cssrules
how can it be done without the text-align? i have read it is due to a bug that actually causes the content of the page to be centered....


Yes, you take advantage of that IE bug to fix the other IE bug (it ignores the mergin auto).

cssrules
02-03-2003, 05:18 PM
thanx...


you have been most helpful....