将几个< li>在右边? [英] Align one of several <li> to the right?
本文介绍了将几个< li>在右边?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="menu">
<ul><li><a href="#" class="current">SocialSpot</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Latest</a></li>
<li><a href="#">Settings</a></li>
<li>Logout</li>
</div>
</ul>
我在网页中有这个。我有css对齐他们。但是,我希望退出按钮在右边对齐,但在同一个栏。
I have this in a webpage. I have css aligning them. However I want the logout button to be aligned to the right but on the same bar. How can I do this without having them all aligned to the right?
推荐答案
CSS:
ul { overflow:auto; }
li { float:left; }
li:last-child { float:right; }
现场演示: http://jsfiddle.net/simevidas/Rs4Sa/
Btw :last-child
伪类在IE8(及以下)中不起作用。如果你想要在这些浏览器中工作,你必须为注销LI项目分配一个类(例如 right
),然后:
Btw the :last-child
pseudo-class does not work in IE8 (and below). If you want it to work in those browsers, you will have to assign a class (e.g. right
) to the Logout LI item, and then:
li.right { float:right; }
现场演示: http://jsfiddle.net/simevidas/Rs4Sa/1/
这篇关于将几个< li>在右边?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文