issue with using % units while using them to set the height and with
Hey folks I'm having some issue while using the % units to the height and width of my div etc.
This is the CSS of the parent container
and this is the CSS of child container
In the above case the computed value of height is
495.031px
but if I do some changes in the above CSS and the new CSS is
then in this case I get computed value of the height as 444.797px
can anyone tell me why I'm getting this difference7 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
but isn't % units relative to the parent container
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
But why there is difference in computed value for vh and %
Also can you give the link of stackoverflow question
Here 80% should be equal to 80vh
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
percentage as a height doesn't work unless there is a declared height.
min-height
won't work here.
That's because, unless the parent has an explicit height, the child element can influence the parent. So, if you declare height: 80%
on the child, that 80% cannot influence the height of the parent.
If it could, it would become a recursive calculation (the height of the parent defines the height of the child which defines the height of the parent...). Because it's a min-height
, the height can be bigger than 100vh
, so doesn't work.Thanks kevin
I recently came across your video about css and other stuff
and I have to say that you are one of the best frontend instructor
Your videos are really helpful and filled with so much abundance of knowledge