Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Centering verticaly an image with position:absolute; top:0; bottom:0;margin:auto

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37339
    Jozsef K.
    Participant

    Does anyone know how can I make this work in ie7 without setting a height on the image?

    #99972
    chrisburton
    Participant

    Why did you give it an absolute position? It should be margin: 0 auto;

    #99982

    There are two main options for vertically centering an element of unknown height with CSS, neither of which work in IE7 (using a pseudo-element, or using display: table. See here for more information: https://css-tricks.com/centering-in-the-unknown/). Your best bet would be to use JavaScript. Here is a jQuery solution, although someone that can do it in JavaScript should be able to come up with something better: http://jsfiddle.net/joshnh/zGw9s/

    #100011
    Jozsef K.
    Participant

    @ChristopherBurton
    margin: 0 auto; is for horizontal centering, I’m interested in both vertical and horizontal centering.The above mentioned method works with the major browsers, but fails in ie7.Of course it works only with widthless, hightless images and probably tables to(their heights are calculated), but not with widthless-hightless p, div tags.


    @joshuanhibbert

    Thank you, so I need to set an alternative method for ie7.

    #100012

    The jQuery solution I posted should work fine in IE7.

    #100013
    Jozsef K.
    Participant

    Thx, but I’m trying to do it only with css.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.