简体   繁体   English

显示方式 <li> 项目从上到下不是从左到右?

[英]How to display <li> items from top to bottom not from left to right?

I have a list items which I am mapping on <ul> <li> . 我有一个要映射在<ul> <li>上的列表项。

<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
<li>Item5</li>
<li>Item6</li>
<li>Item7</li>
<li>Item8</li>
<li>Item9</li>
<li>Item10</li>
<li>Item11</li>
</ul>

It display the items on the page like from left to right: 它从左到右显示页面上的项目:

Item1 Item2 Item3 Item4 Item5
Item6 Item7 Item8 Item9 Item10
Item11

I want to display them from top to bottom like 我想像从上到下显示它们

Item1 Item4 Item7 Item10
Item2 Item5 Item8 Item11
Item3 Item6 Item9 

How can I display them from top to bottom? 如何从上至下显示它们?

int count = 0;
<ul style="display:inline" >
    if(count < items.length)
    {
        print("<li>");
        print("<ul>");
        for(int a = 1 ; count < items.length && a <= 3 , count++ , a++)
        {
               print("<li>" + items[count].Name + "</li>");
        }
        print("</ul>");
        print("</li>");
    }
</ul>

May this pseudocode help you. 希望此伪代码对您有所帮助。

you could do this with just HTML and some simple CSS, but you'd have to make separate lists for each set of items you wanted separted by column: 您可以只用HTML和一些简单的CSS来做到这一点,但是您必须为要按列分开的每组项目分别创建列表:

<style>
ul {
    margin-top:0px;
    margin-left:0px;
    float:left;
}

</style>

<html>
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>
<ul>
  <li>Item 4</li>
  <li>Item 5</li>
  <li>Item 6</li>
</ul>
<ul>
  <li>Item 7</li>
  <li>Item 8</li>
  <li>Item 9</li>
</ul>
</html>

Unless you have to support IE < 10 use CSS3 columns: 除非必须支持IE <10,否则请使用CSS3列:

https://developer.mozilla.org/en/CSS3_Columns https://developer.mozilla.org/en/CSS3_Columns

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

相关问题 列表中的项目从上到下而不是从左到右 - List items in columns from top to bottom instead of left to right 如何制作2列布局,其中项目从上到下(不是从左到右)开始? - How do I make a 2 column layout where items starts from top to bottom (not left to right)? 如何从右到左以及从上到下调整div元素的大小 - How to resize div element from right to left and top to bottom 如何从右上角到左下角获得渐变色 - How to get the gradient color from top right to bottom left corner 从右下到左上填充SVG - Fill SVG from bottom right to top left 从左侧和右侧计算溢出的列表项。 (不是顶部/底部) - Count overflowed List items from both Left and Right side. (Not top/bottom) 左侧Para文本强制从Right li浮动到底部? - Left Para text forced to bottom from Right li float? 浮动div从左到右到顶部和底部,其中左div位于底部,而右div位于顶部 - Floating div from left to right to top and bottom where left div sit bottom and right div top 如何实现从右到左,从下到上的文本键入动画? - How I can realize an animation of text typing from right to left and from bottom to top? 如何使用干净的HTML标记从上到下,然后从右到左垂直放置元素? - How to lay down elements vertically from top to bottom, and then from right to left, using a clean HTML markup?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM