Forums

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

Home Forums CSS Relationship between height and width of parent and child div.

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

    If i set up a main div with max-height and max-width , why the child div flows out off the main div. I want to put an image in a child div inside a parent div.
    can anyone explain me the relationship between parent-child div relationship for width and height with some examples.
    Thanks in advance.

    #280406
    Paulie_D
    Member

    Perhaps you could demonstrate the issue with a Codepen.io demo.

    That said, if you might have overflow you should have code to deal with it.

    https://developer.mozilla.org/en-US/docs/Web/CSS/overflow

    #280409
    Prakhar
    Participant

    here is the codepen
    https://codepen.io/prakhar-monga/full/REoYKv
    i want the image to fit in its parent div.
    i want to understand the height, width relationship of parent child div

    #280412
    Paulie_D
    Member

    An image will always be it’s natural size unless told to be something else.

    If you want it to fit it’s parent then max-width:100% would so the trick.

    Aspect ratios can be a little tricky but that’s another question.

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