如何设置像桌子一样的无序列表?

use*_*018 6 html css

我只有一个<UL>,在那个我们有一组<LI>

 <ul>
   <li>1<li>
   <li>2<li>

   <li>3</li>
   <li>4<li>

 </ul>
Run Code Online (Sandbox Code Playgroud)

现在我想把它们显示为TABLE,请用CSS帮助我,我们如何在下表格式中显示上述UL/LI的表格,2个LI设置在一个TR(两个TD)中等等....

在此输入图像描述

rai*_*7ow 7

嗯,这是一个可能的解决方案:

ul {
    width: 450px;           /* change it to whatever you like */
    position: relative;

    /* these should be probably already set up by `reset.css` */ 
    list-style-type: none;
    margin: 0;
    padding: 0;
}

ul:before, ul:after {
    text-align: center;
    display: block;
    border: 1px solid black;
    border-bottom: 0;
    width: 48%;
}

ul:before {
    content: 'col1';
    border-right: 0;    
}

ul:after {
    content: 'col2';
    position: absolute;
    top: 0;
    left: 48%;
    margin-left: 1px;    
}

li {
    text-align: right;
    width: 48%;
    float: left;
    border: 1px solid black;
    margin-bottom: -1px;
}

li:nth-child(even) {
    margin-left: -1px;
}
Run Code Online (Sandbox Code Playgroud)

它有效(JSFiddle ;在Chrome,Firefox和Opera中测试; nth-child(even)选择器在IE8中明显失败,所以你必须用类或其他方法来模拟它;但除此之外它仍然是可靠的),但我承认我对此感到内疚.)

PS.如果您想填充添加到"细胞"的内容,不要忘记改变它们的宽度,以及像在这里:

li {
    width: 47%;
    padding-right: 1%;
}
Run Code Online (Sandbox Code Playgroud)