Telash
Telash•2y ago

Why I have to put content inside those divs in order to make them appear?

If I erase the word "content", the blue and red divs wont appear, why is that?
11 Replies
dfg
dfg•2y ago
height: 100% means 100% of the parent container, and by default all elements, including body and html, will only have enough height to fit their contents. So, without any content, the div won't have any height, even though it has 100% of the parent, because there's no reason for the parent to have any height. If you add
html, body { height: 100%; }
html, body { height: 100%; }
you might find the behavior you're expecting
Telash
TelashOP•2y ago
Thank you 🙂 I did added the line you told me to add and it worked, but the question is now, what is the default height of html and body? is it fit-content? when adding height:100% to html and body, that's simply telling the internals "i want html and body to be as tall as the view port"? if so, what is the parent of html and body, that they are taking measurements from, the view port?
Telash
TelashOP•2y ago
Ah, I see the the default height of the body is 0
Telash
TelashOP•2y ago
so 30% out of 0 is 0
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
dfg
dfg•2y ago
if you want to have a footer stuck at the bottom of the visible screen, thats a good enough reason to change the height plenty of reasons to change the default root height tbh
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
dfg
dfg•2y ago
please provide an alternative solution instead of "revisit fundamentals" "that's not recommended"
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Telash
TelashOP•2y ago
@DanielFGray I still dont understand - if % takes value from the parent, and the default height of html is 0, that means the height of the body will be 0 if its set to 100%, and therefore the tag <c3> height will be 0px too if i set it to 10%, can you please clarify here?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View