Forums

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

Home Forums CSS [Solved] Inline equivalent of background-position?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #175700
    modiophile
    Participant

    I have an inline image that I’m trying to horizontally/vertically center inside a div of a smaller size with overflow: hidden, how do I do that by targeting the img tag itself and not using “background-position” on the parent container itself?

    Example

    #175702
    Senff
    Participant

    If you know the width/height of the image, then it’s pretty easy: http://codepen.io/senff/pen/tfgks

    If you don’t know the image size, it will be a little trickier and you may have to use some Javascript.

    #175727
    Senff
    Participant

    That image is not really centered in Chrome, so you may still need prefixes:

    http://codepen.io/senff/pen/Fworh

    #176155
    modiophile
    Participant

    Sweet! Thanks Jacob!

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