0

http://stackoverflow.com/questions/10487292/position-absolute-but-relative-to-parent
Hey, so, please check link above. There is first resolving answer, which was resolving my problem. But now I have problem, that DIV isn't displaying well when it is set to position: relative and position: fixed does work correctly. DIV itself has no children, first I am trying to get parent there, I will care about children later.

#div {
    position: relative;
    left: 0;
    top: 0;
    width: 15%;
    height: 100%;
    background-color: rgba(0, 0, 0, 1);
}

There appeears black line in top left, it is 15% width and hmmm, 0,8% high? It looks like it has no height set, but it does.
If I change position: relative to position: fixed (what is actually what I need) it works.

Edited by RikTelner

2
Contributors
1
Reply
20
Views
3 Years
Discussion Span
Last Post by Luckychap
1

height of an relative positoned element in % is caclulated on the basis of its parents. You need to set height of parent. In case parent is body you can add following css to make your dive work:-

html,body{height: 100%;}

Thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.