I’m currently working on my portfolio and I’m having a rather frustrating issue. I’m trying to get my silver navbar background color to extend to 100% width, but doing so completely undoes my styling that moves my navbar to the right so it stays more visible. I’m not sure how to fix that, or even what if there’s something I’m doing wrong. And moving the width styling above the top and right styling still undoes the right: 10px; styling. The first link is of my portfolio without the width added to the navbar and the second link is with the width added so you can see what I’m talking about.
First, thank you for your response. I greatly appreciate the help.
Second, what is justify-content: end; and gap: 2rem; for and what do they do?
Third, out of curiosity, do you have any idea why setting the width is resetting the right: 10px; CSS styling? (Or is this just a CodePen glitch thingy because this isn’t the first time I’ve had this issue)
Thanks in advance and thanks again for the help. I’m gonna try what you suggested and see if that fixes the issue.
If you use this method, You may want to consider adding some padding on the right and the left of the nav to balance the aesthetics, and minimize those gaps :
justify-content controls how flex items are distributed/positioned along the main axis. end is to the right (with the default reading direction left to right and default flex-direction of row).
gap is like a margin around the flex items (conceptually anyway). It creates space between the flex items.
It doesn’t. I think you are mistaking the nav box for the elements inside it (i.e. the links).
right is the distance between the element’s right edge and the right edge of its containing block.
It is easier to see if you create a relatively positioned element as the container and set the child to be absolute.