dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: aligniing divs - the sequel

  1. #1
    Join Date
    Nov 2002
    Posts
    15

    aligniing divs - the sequel

    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...

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


    how can it be done...

    Thanl u in advance....

  2. #2
    Join Date
    Nov 2002
    Posts
    984

    Re: aligniing divs - the sequel

    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...

    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;}

  3. #3
    Join Date
    Nov 2002
    Posts
    15
    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?

    Thank u in advance....

  4. #4
    Join Date
    Nov 2002
    Posts
    984
    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).

  5. #5
    Join Date
    Nov 2002
    Posts
    15
    thanx...


    you have been most helpful....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles