Centering Image Vertically & Horzantaly With CSS

Discussion in 'CSS' started by SNaRe, Dec 17, 2008.

  1. #1
    I have a picture and i want to center Image Vertically & Horzantaly With CSS. It must be centered in all browsers and resolution.
    Waiting for your help
     
    SNaRe, Dec 17, 2008 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Not positive about this.

    Put it in a div and set the padding for that div to achieve the look you want padding: T R B L
     
    Colbyt, Dec 17, 2008 IP
  3. rustang289

    rustang289 Peon

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    are you trying to center it in the middle of the entire page or are you just centering it in one part of the page?

    you could make it a class and apply it to a div tag somthing like this

    .img {
    position:relative;
    width:100px; (change this to your image size in px or percent)
    height:100px; (change this to the height of your image
    background-image:url('images/round_04.png');
    background-repeat:no-repeat;
    padding: 0px 50px 0px 50px; (this padding is top,left,bottom,right
    float:right or left this will alow you to put it to one side or the other then fine tune with padding.
    }

    play with the padding to acheive proper placement you can even use -0px
    positioning is pretty easy when you get the hang of it always write clean code you'll apreciate it later
     
    rustang289, Dec 17, 2008 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    See vertical centering. There are three articles linked from that page which should be of help to you.

    cheers,

    gary
     
    kk5st, Dec 17, 2008 IP