简体   繁体   English

在Div中对齐li元素

[英]Aligning li Elements in a Div

I need to align 3 different elements in my div. 我需要在div中对齐3个不同的元素。 They are in a ul list: Left, Center and Right. 它们在ul列表中:左,中和右。

I tried to use float: right for the right element, and margin: 0 auto with a width for the element in the center. 我尝试对正确的元素使用float:right,对中间的元素使用margin:0 auto并带有宽度。 But still it doesn't align automatically. 但是仍然不能自动对齐。

The elements can also be images, not only text. 元素也可以是图像,而不仅仅是文本。 http://jsfiddle.net/PwmrC/ http://jsfiddle.net/PwmrC/

display:table and table-cell may be your solution. display:tabletable-cell可能是您的解决方案。 Here is the fiddle demo . 这是小提琴演示

Later edit: Reworked example 稍后编辑: 重做示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM