Imagine this:
I have a navbar which is divided into three divs. One for the logo, one for the links, and one for some content which I do not know the size of.
I want the left-most content and the right-most content to be equally sized, but also take as little space as possible. This way my navigation links will be perfectly centered and have as much space as possible for when the page is smaller.
My first approach was to use display: grid;
and grid-template-columns: 1fr 3fr 1fr;
. However, this approach will either cause the left-most and right-most divs to take more space than necessary, or there wont be enough space for the content at all. Therefore, that is off the table.
My second approach is what I tried to illustrate below, where I have used display: flex;
and justify-content: space-between;
. Now the left-most and right-most divs are taking as little space as possible which is a step in the right direction. However, because the left-most div is not equally as wide as the right-most div, my links are no longer centered propertly.
I dont want to give both divs a fixed width, because I like how the width is as small as possible and the width of my right-most div may vary depending on e.g. the length of my users username. So is there a way I can set the width of the left-most div to be equal to the right-most any how using CSS?
how my navbar is now:
[LOGO][-------------------LINKS--------------------][LARGE_CONTENT]
what I want:
[LOGO----------][---------------LINKS---------------][LARGE_CONTENT]