Bring the image to center

Discussion in 'HTML & Website Design' started by ajaykumarmeher, Sep 26, 2007.

  1. #1
    Hello frnds,

    I m trying to bring the header image which reads Jharsuguda to the center part. Tried with float: none but it did not work.

    Any suggestion???

    Site is http://jharsuguda.info
     
    ajaykumarmeher, Sep 26, 2007 IP
  2. jared

    jared Peon

    Messages:
    231
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well before you even worry about centering the image you need to fix the rest of you site.

    If you view it in Firefox or Opera everything is really messed up. Always check all browsers!
     
    jared, Sep 26, 2007 IP
  3. longhornfreak

    longhornfreak Well-Known Member

    Messages:
    2,067
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    140
    #3
    You need to set margins to fix it. it looks to me like you got it centered, but in FF its really messed up. And in IE there are no margins defined so it looks weird, I think you even have the standard top 20px margin for the body which is why your header image isn't touching the top of the viewing screen.
     
    longhornfreak, Sep 26, 2007 IP
  4. ajaykumarmeher

    ajaykumarmeher Banned

    Messages:
    296
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I m in IE 7 and it is looking just fine. I centered the image by specifying left margin. Thanks
     
    ajaykumarmeher, Sep 26, 2007 IP
  5. longhornfreak

    longhornfreak Well-Known Member

    Messages:
    2,067
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    140
    #5
    don't just specify a left margin do one of these

    if in xhtml

    <center>yoursite.com/images/banner.gif/</center>

    if using CSS

    margin-left: auto;
    margin-right: auto;
     
    longhornfreak, Sep 27, 2007 IP
  6. ajaykumarmeher

    ajaykumarmeher Banned

    Messages:
    296
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the trick. Do you mean to say that apart from left margin I hv to put this <center>...</center> tag?
     
    ajaykumarmeher, Sep 27, 2007 IP
  7. jared

    jared Peon

    Messages:
    231
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    dude... never.. i repeat... never... use the <center> tags.

    Those tags depreciated a long time ago with <blink> (sarcasm)

    But really. You should never use <center>. If you want to center a div just use the auto margin:
    margin: 0 auto;

    if you want to center text just assign the parent element:
    text-align: center;

    if you want to center an image you can usually get away with that by making it a block element:
    display: block;

    cheers
     
    jared, Sep 27, 2007 IP
  8. ajaykumarmeher

    ajaykumarmeher Banned

    Messages:
    296
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Got it Jared....many thanks
     
    ajaykumarmeher, Sep 27, 2007 IP