Hello I’m new to HTML/CSS and I need help for something :
my page
How can I put PORTFOLIO to the left edge of my page.
Here is my code :
HTML:
<nav>
<ul id="nav">
<li class="nav-item">PORTFOLIO</li>
<li class="nav-item">Présentaion</li>
<li class="nav-item">Réalisations</li>
<li class="nav-item">Mon CV</li>
<li class="nav-item">Me contacter</li>
</ul>
</nav>
CSS :
#nav{
display : flex;
text-transform: uppercase;
justify-content:center;
align-items: center;
}
.nav-item{
text-decoration : none;
list-style : none;
text-transform: uppercase;
margin-right: 2em;
font-family: 'Oswald', sans-serif;
}
.nav-item:first-child{
font-size:30px;
}
So I created a list to make a nav bar, I use display fex so it would be in line, I use justify-content to center my nav bar and align-items to center it horizontally.
What can I put in .nav-item:first-child for the PORTFOLIO text to be on the very left of the page.
This is what I would like to achieve page
Thanks for reading me and helping me out
I tried justify-self, the left property, align self …
2
Answers
The solution will differ depending on what visual result you want to get. Judging by the context, you want the "Portfolio" item to be at the edge AND all other elements to be at the center, right?
Of course, you could just do a simple absolute positioning here, but in that case it will overlap with the buttons if the screen width is not enough, so it’s better to take another approach:
flex: 1
property to your nav buttons container so it takes up all the available spaceSee the following example:
Be careful though: this design will not look good for small screens. Good luck in learning Web!
There is already an answer. I just added mine just in case.