0

我正在尝试更改 DataLife 引擎模板的外观,我想知道您是否可以帮助我进行对齐。

我有一些信息显示在一个列中,如下所示:

<div class="short-description">
    <div  class="table">
      <ul class="table">

        <li>A</li>

        <li class="odd">B</li>

        <li>C</li>

        <li class="odd">D</li>

        <li>E</li><br>

      </ul>
    </div>
</div>

这看起来像

A
B
C
D
E

我希望它们像这样显示:

A    B    C
D    E

每个“单元格”的内容可以不同。例如,如果B有更多内容,我想调整列如下:

A    B    C
     B
     B
D    E

因此它会向下延伸,直到显示所有信息。类奇数只是改变了该单元格的颜色。

这是jsfiddle 演示

4

2 回答 2

3

为此,您可以将列表项显示为inline-block元素,如下所示:

ul {
    list-style: none;
    padding: 0;
    font: 0/0 a;  /* Remove space characters between inline-block elements */
}

ul li {
    font: 16px/1 Arial, sans-erif;  /* Reset the font property */
    display: inline-block;
    vertical-align: top;     /* <-- keep the inline elements at the top    */

    background-color: #ddd;  /* For the demo */
    margin: 5px;             /* For the demo */
    width: 200px;            /* For the demo */
}

JSFiddle 演示

于 2014-01-28T15:23:12.720 回答
1

看看jsfiddle

.table ul{
    list-style: none;
    width: 180px;
    height: auto;
}

.table li{
    display: inline-block;
    vertical-align: top;
    width: 50px;
    background: rgba(0,0,0,0.2);
    margin: 3px;
}
于 2014-01-28T15:28:33.170 回答