I’m fairly new to web development and I want to make sure that my nav bar can expand to fit all of it’s contents inside. But when I do
height: fit-content
The height remains at 0 pixels and I don’t know why. There is content inside of it so by my understanding of it, the nav bar should expand. Here’s my html:
I coloured the anchors red so you can see they are full height but they would be 70px anyway because you gave them a height in pixels so the fit-content would be superfluous anyway.
I can’t really see what you were expecting and I don’t see that fit content is any use for you here as its more usable when referring to width.
An element will automatically grow with its children unless they are removed from the flow in some way (see my last comment below).
You can’t use that html anyway because a ul can only contain list elements (li) as direct children. You would need to wrap the anchors in a list element (or not use a ul as a wrapper but a nav element again).
Without knowing the effect you want to achieve and where you are seeing a problem it will be hard to give more specific advice.
You have made the ul position:fixed so the ul and anchors will be removed from the flow and your header element will be zero pixels high unless it has in-flow content. Perhaps that’s what you meant?