'Make an item in list align to right using CSS 3
I have a list as follows:
<ul id="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Work</a>
<ul>
<li><a href="#">CSS Development</a></li>
<li><a href="#">Graphic Design</a></li>
<li><a href="#">Development Tools</a></li>
<li><a href="#">Web Design</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Feedback</a></li>
</ul>
I am attaching an image of so far what I have done.

In this menu, I want to align feedback to the right side. How can I do it?
Solution 1:[1]
Just use float: right;:
<ul id="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Work</a>
<ul>
<li><a href="#">CSS Development</a></li>
<li><a href="#">Graphic Design</a></li>
<li><a href="#">Development Tools</a></li>
<li><a href="#">Web Design</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Contact Us</a></li>
<li style="float: right;"><a href="#">Feedback</a></li>
</ul>
You can check the demo here.
Solution 2:[2]
Aside from float you can also use position:absolute inside of a position:relative container. (Inline CSS for example purposes only.)
<ul id="menu" style="position:relative;width:1008px;height:40px;display:block;">
<li class="right" style="position:absolute;right:20px;">
<a href="#">Feedback</a></li>
Solution 3:[3]
I had the same question but for the whole list.
Float does not realy work there, so here is what worked for me:
ul{
direction:rtl;
}
This way all your li elements including their ::marker's will be pulled to the right of the parent container.
You can also combine this with selectors to just move single li elements.
ul:first-child,
ul:nth-child(2),
ul:last-child{
direction:rtl;
}
Solution 4:[4]
This will pull the entire menu to the right and have the dropdown sub menu pull right also instead of displaying off the screen.
<div class="top-menu">
<ul class="nav navbar-nav pull-right"><li class="dropdown dropdown-user">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<i class="icon-settings"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu pull-right">
<li>
<a href="page_user_profile_1.html">
<i class="icon-user"></i> My Profile
</a>
</li>
</ul>
</li>
</ul>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Minko Gechev |
| Solution 2 | Peter Mortensen |
| Solution 3 | Ebert.L |
| Solution 4 | JoshYates1980 |
