简体   繁体   English

在HTML列中排列列表的间距?

[英]Spacing a list in columns in HTML?

I've created a <ul> and <li> list and got a ton of different information in it. 我创建了一个<ul><li>列表,并在其中包含了大量不同的信息。 Is it possible to space different pieces of information in one <li> over the page, like it had columns? 是否可以在页面的一个<li>中将不同的信息片段<li> ,就像它具有列一样?

Like the first word of <li> is aligned at the left side of the page, then the second is always at the first 1/4 the 3rd at half and the 4th at 3/4, for every <li> ? 就像<li>的第一个单词在页面的左侧对齐一样,那么对于每个<li> ,第二个单词总是在前1/4处,第三个在一半处,第四个在3/4处。

Is this possible, if yes, how is it done? 如果可以的话,这有可能吗? If needed I can post my PHP/HTML Code in here (though it's dynamic). 如果需要,我可以在此处发布我的PHP / HTML代码(尽管它是动态的)。

EDIT: Here is the Code: http://jsfiddle.net/woz1r55e/ :) 编辑:这是代码: http : //jsfiddle.net/woz1r55e/ :)

Thanks beforehand already :) 预先感谢了:)

In your CSS define two classes 在您的CSS中定义两个类

.inline-block
{
    display: inline-block;
}

.col
{
    width: 25%;
}

and then define containers for whatever you want in those columns. 然后在这些列中为您想要的内容定义容器。

<div>
    <div class="inline-block col">List 1
        </div>List 2<div class="inline-block col">
        </div>List 3<div class="inline-block col">
        </div>List 4<div class="inline-block col">
    </div>
</div>

Source: 4 column CSS layout - Fluid 来源: 4列CSS布局-流畅

I think this is what you mean: 我认为这是您的意思:

http://jsfiddle.net/woz1r55e/1/ http://jsfiddle.net/woz1r55e/1/

I added this css: 我添加了这个CSS:

ul ul ul li {
    display: inline-block;
    width: 25%;
}

I'd recommend giving either the <li> a class to make it inline block or to give the third <ul> class and make it's children inline-block 我建议给<li>一个类以使其成为内联块,或者给第三个<ul>类以使其为子类一个内联块

Create different css classes for each "column": 为每个“列”创建不同的CSS类:

ul.Col1 { margin-left: 10px; }
ul.Col2 { margin-left: 210px; }
ul.Col3 { margin-left: 410px; }

<ul class="Col1">
   ...
</ul>
etc...

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

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