I want to put all the elements to right. How can I do it?Like this
Here is my navbar
I want all the items in ul to be at left of navbar as like in the figure.
I am expecting the list items to right or left how can I do it.
the float is not working for some reason am I making some mistakes or anything someone help me.
nav {
padding: 40px 50px;
background-color: black;
}
ul {
list-style-type: none;
padding: 0vh 15vh;
}
li {
color: white;
text-align: center;
}
@media screen and (min-width:768px) {
nav {
padding: 20px 20px;
height: 30px;
}
ul {
display: flex;
flex-direction: row;
}
li {
padding: 0px 20px;
display: inline;
float: left;
}
}
* {
font-family: Arial, Helvetica, sans-serif;
}
<nav class="navbar">
<ul>
<li>About</li>
<li>Courses</li>
<li>Forum</li>
<li>Learning Paths</li>
<li>Contact</li>
</ul>
</nav>
3
Answers
Set
justify-content: flex-end
on the list:To move all the list items to the right, you can add the CSS property justify-content: flex-end; to the ul element. This will align all the items to the right of the navbar. Here’s the updated CSS:
I think this is what u want to do, u doesn’t need to use float( btw u cant use float when using dipslay:flex)
Without padding items will be on flex end as in the screenshot.