【问题标题】:How to sort list in vertical?如何对列表进行垂直排序?
【发布时间】:2012-12-13 08:15:41
【问题描述】:

我在HTML and CSS 下方使用此代码对vertical 中的列表进行排序,输出为horizontal 排序。

我的示例代码:

<!DOCTYPE HTML>
<html>
  <head>
    <title>Tiles</title>
    <style type="text/css">
    #tiles {
        list-style: none;
        margin: 0px;
    }
    #tiles li {
        float: left;
        margin: 20px;
        width: 300px;
        height: 200px;
        background-color: #dddddd;
        font-size: 72px;
        text-align: center;
        vertical-align: middle;
    }
    </style>
  </head>
  <body>
    <ul id="tiles">
       <li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li>
    </ul>
  </body>
</html>

输出是:

但是,我想要这个输出。

请给我vertical中的排序列表代码。

【问题讨论】:

    标签: html css


    【解决方案1】:

    使用CSS columns: (JSFiddle)

    ul {
        column-width: 380px;
        -webkit-column-width:380px;
        -moz-column-width: 380px;
        height:440px;
    }
    
    #tiles {
        list-style: none;
        margin: 0px;
    }
    #tiles li {
        /* float: left; */
        margin: 20px;
        width: 300px;
        height: 200px;
        background-color: #dddddd;
        font-size: 72px;
        text-align: center;
        vertical-align: middle;
    }
    

    请注意,这在 IE≤9 中不起作用。

    【讨论】:

      【解决方案2】:

      CSS

          #tiles {         
              list-style: none;        
              margin: 0px; 
              width:300px;
              height:200px;   
                }     
           ul   {
              column-width: 85px;
              -webkit-column-width:85px;
              -moz-column-width: 85px;
              height:60px;
               }
      
          #tiles li {         
              float: left;
              margin: 20px;        
              width: 50px;         
              height: 30px;         
              background-color: #dddddd;         
              font-size: 16px;         
              text-align: center;         
              vertical-align: middle;     }
      

      fiddle

      这是你的输出图像的裹尸布

      【讨论】:

        猜你喜欢
        • 2018-09-15
        • 2013-02-06
        • 2011-06-03
        • 2011-10-19
        • 2020-11-12
        • 1970-01-01
        • 1970-01-01
        • 2012-12-16
        相关资源
        最近更新 更多