2012-11-04 123 views
0

我很难在文档中集中li元素。li元素居中困难

我把一个包装(<div align="center">围绕li元素但一点运气。

这似乎是唯一的定心每个li元素的标题和不li元素的整个块。我想为中心(即在一个div的中间)的Priority, Round 1 and Round 2整块

这是到目前为止我的代码:http://jsfiddle.net/nTcBk/

HTML

<div> 
<div align="center"> 
<ul class="round"> 
     <li class="current-round" style="cursor: default; "> 
      <div>Priority</div> 
      <span>Ending 01/11/2012</span></li> 
     <li style="cursor: default; "> 
      <div>Round 1</div> 
      <span>Starting 01/12/2012</span></li> 
     <li style="cursor: default; "> 
      <div>Round 2</div> 
      <span>Starting 01/01/2013</span></li> 
</ul> 
</div> 
</div> 

CSS

.round { 
    list-style: none; 
    margin: 0; 
    padding: 0; 
    width: 100%; 
} 
.round li { 
    color: #DDD; 
    cursor: pointer; 
    float: left; 
    font-size: 18px; 
    padding-right: 20px; 
} 
.round li span { 
    font-size: 12px; 
    display: block; 
} 
.round .current-round { 
    color: #2a145d; 
    cursor: auto; 
} 
​ 

在此先感谢

回答

2

下─http://jsfiddle.net/nTcBk/1/ 代替:

.round { 
    width:100%; 
} 

使用:

.round { 
    display:inline-block; 
} 
+0

太糟糕了,这并不工作在IE6/7,因为的浮动列表元素。 – aefxx

1

对齐属性是指(并且是已弃用)。取而代之的对齐=“中心”,您可以在CSS类在你的CSS样式表添加到您的div <div class="align-center">

然后你做:

.align-center {text-align:center}

+0

不解决问题。 – Alohci

+0

需要从'.round li'中删除'float:left;'并添加display:inline-block。 要在IE7中工作,请添加'* zoom:1; *显示:内联;' –