left margin of div different in different browser ..

Discussion in 'HTML & Website Design' started by nandanamnidheesh, May 10, 2009.

  1. #1
    i had given margin left : properties in style sheet for a Div tag .. in mozilla i need to give 180 px to make it look align to center ... but in IE i need to change it to 30 Px .. so if one is correct .. another one look bad ...wht to do ???
     
    nandanamnidheesh, May 10, 2009 IP
  2. nandanamnidheesh

    nandanamnidheesh Active Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    pls help ?
     
    nandanamnidheesh, May 10, 2009 IP
  3. Astroman

    Astroman Well-Known Member

    Messages:
    2,355
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    135
    #3
    It's hard to say without seeing it, but it could be a problem with Padding on a surrounding div?
     
    Astroman, May 10, 2009 IP
  4. TechnoGeek

    TechnoGeek Peon

    Messages:
    258
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello, nanda.

    As Astroman said, it is hard to tell without seeing. Could you post the style sheet, or at least the interesting part? In CSS many times the cause of a problem is not where one may think, but in another part of the sheet. The result also depends on your HTML: what things you assigned which classes, and so on. That is why without having the HTML page and the CSS sheet is difficult to say why is something happening.

    Cheers.
     
    TechnoGeek, May 10, 2009 IP
  5. jlhaslip

    jlhaslip Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Give the div a specified width and use margin: 0 auto; on the div should work to centre it in all Display Monitors.
     
    jlhaslip, May 10, 2009 IP
  6. nandanamnidheesh

    nandanamnidheesh Active Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #6
    actually b4 i had given .. margin-left: 50px; ... and now i changed to margin: 0 auto; now it ok.. thr is only small difference ... but one thing i found is .. in IE if there is margin: 0 auto; or not .. div will be aligned to center .. and in firefox not ...
     
    nandanamnidheesh, May 11, 2009 IP
  7. Astroman

    Astroman Well-Known Member

    Messages:
    2,355
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    135
    #7
    Margin auto doesn't always work properly in some versions of IE, so you have to get around it by making the div/element outside it have text-align:center, then put text-align:left for your centered div to counteract the previous command, unless you want the text centered of course..
     
    Astroman, May 11, 2009 IP