Forums

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

Home Forums CSS how do i use the auto selector to place an image tag in the middle of a DIV tag

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

    hi everyone.

    i want to place an image in the middle of a “div tag”.

    i tried using the auto selector to do this but it does not work.

    so, i was wondering, does the auto selector work with Img tag. i tried the following;


    .picmiddle img {
    margin:0 auto 0 auto;

    }
    #110737
    Kitty Giraudel
    Participant

    Images are inline elements by default. Set display block then margin: 0 auto to center it.

    #110754
    andreea115
    Participant

    ah. that is great. thanks HugoGiraudel.

    one question; do you mean i should margin 0 first and then subsquently use the auto

    warm regards

    Andreea

    #110756
    Paulie_D
    Member

    He means that


    margin: 0 auto;

    is the same as


    margin:0 auto 0 auto;

    but add this


    display:block;

    Like this: http://codepen.io/Paulie-D/pen/grosf

    #110757
    andreea115
    Participant

    wow. great. thanks guys.

    i really appriciate this

    #110766
    Kitty Giraudel
    Participant

    I guess I wasn’t clear enough. Sorry. :)

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