Forums

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

Home Forums CSS 100% height of child when height of parent is not set?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44714
    VladimirKrstic
    Participant

    How to make child element fill 100% height of his parent when parents height is not set? Is it possible just with CSS?

    Thanks in advance.

    #134804
    JTParrett
    Participant

    You could try setting the parents position to relative (position: relative;). Then set the child’s position to absolute. You should then be able to give the child top and bottom values (top: 0; bottom: 0;) making it stretch out the entire height of the parent. However this could cause other issues such as the child’s content overflowing out of the child container.

    Hopefully this makes sense! ;D

    #134806
    Paulie_D
    Member

    If no height is set on a parent div it will only have the height of the child.

    So perhaps you are missing something.

    If you could create a Codepen to explain the issue we might be able to help further.

    #134807
    wolfcry911
    Participant

    I think you need to rephrase the question. Unless a child is position: absolute or a float, the parent will encompass the child and therefore the child will be 100% of it’s parent’s height. I’m guessing you mean 100% of the viewport?

    #134808
    VladimirKrstic
    Participant

    @JTParrett

    Perfectly, does exactly what i wanted. Just gave him (right: 0) because i had (float: right) on child. Thank you man.


    @wolfcry911
    Yup, child was floated.


    @Paulie_D
    This is not a main content, it is just some kind of side bar for social buttons, names of authors and photographers.

    Thank you all, Cheers!

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